daquity36 Posted December 1, 2012 Share Posted December 1, 2012 (edited) Hello, I'm not very experienced with Prestashop/Smarty. How do I get the category of lastProductAdded? I am trying to make the "continue shopping" button redirect to the category of the last product added. <a href="{$link->getCategoryLink($lastProductAdded.category->id)|escape:'htmlall':'UTF-8'}" class="button_large" title="{l s='Continue shopping'}">« {l s='Continue shopping'}</a> The following code doesn't seem to work, giving category id of 0 for some reason. Any help would be much appreciated. Thank you! Edited December 2, 2012 by daquity36 (see edit history) Link to comment Share on other sites More sharing options...
daquity36 Posted December 2, 2012 Author Share Posted December 2, 2012 SOLVED IT with the help of someone on stackoverflow. The following is correct: <a href="{$link->getCategoryLink($lastProductAdded.id_category_default)|escape:'htmlall':'UTF-8'}" class="button_large" title="{l s='Continue shopping'}">« {l s='Continue shopping'}</a> For Prestashop 1.4, however, you have to go to classes/cart.php and modify the function getLastProduct as following: public function getLastProduct() { $sql = ' SELECT cp.`id_product`, cp.`id_product_attribute`, p.`id_category_default` FROM `'._DB_PREFIX_.'cart_product` cp JOIN `'._DB_PREFIX_.'product` p ON (cp.`id_product` = p.`id_product`) WHERE `id_cart` = '.(int)($this->id).' ORDER BY cp.`date_add` DESC'; $result = Db::getInstance()->getRow($sql); if ($result AND isset($result['id_product']) AND $result['id_product']) return $result; return false; } Link to comment Share on other sites More sharing options...
Magicalname Posted December 15, 2014 Share Posted December 15, 2014 is there any solution for this in 1.6 Version??? Link to comment Share on other sites More sharing options...
Recommended Posts