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 1, 2012 Author Share Posted December 1, 2012 (edited) I also have tried, <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> Edited December 1, 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...
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