ldelucky Posted November 19, 2015 Share Posted November 19, 2015 Hola, muy buenas. Quería meter en mi tienda unos botones de anterior y siguiente dentro de la página del producto, que me lleven de un producto a otro. Como no conozco muy bien php conseguí este código rebuscando por ahí. product.tpl<a class="prev" href="index.php?id_product={$product->getPrevId($category->id)}&controller=product&id_lang=1">Articulo anterior</a><a class="sig" href="index.php?id_product={$product->getNextId($category->id)}&controller=product&id_lang=1">Siguiente articulo</a> Product.phppublic function getNextId($category){$result = Db::getInstance()->ExecuteS(' SELECT `id_product` as id FROM `'._DB_PREFIX_.'product` WHERE `id_category_default` = '.(int)$category);$ret = $this->id;$sal = 0;foreach($result as $id){if($sal==1){$ret = $id['id'];$sal = 2;}elseif($sal==0){if((int)$id['id']==(int)($this->id)){$sal=1;}}}return $ret;}public function getPrevId($category){$result = Db::getInstance()->ExecuteS('SELECT `id_product` as id FROM `'._DB_PREFIX_.'product` WHERE `id_category_default` = '.(int)$category);$ret = $this->id;$sal = 0;foreach($result as $id){if($sal==0){if((int)$id['id']==(int)($this->id)){$sal=1;}else{$ret = $id['id'];}}}return $ret;} Lo probé en una web sin urls amigables y funcionaba perfectamente, pero al probarlo en una web con urls amigables no me funciona, simplemente me vuelve a recargar la página del producto en el que estoy. Alguien me podría decir que tengo que cambiar o si hay alguna manera mejor de hacerlo? Muchas gracias Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now