alain91 Posted October 26, 2016 Share Posted October 26, 2016 (edited) Prestashop v 1.6.1.x he second hook "actionProductListModifier" may have side effects because it can modify nbProducts and cat_products and some actions like pagaination have allready be made. It seems that this second hook can be delete becasue there is not really a great difference with the first one "actionProductListOverride" and it is best to limit the hooks. then I suggest the following refactoring : /** * Assigns product list template variables */ public function assignProductList() { $hook_executed = false; Hook::exec('actionProductListOverride', array( 'nbProducts' => &$this->nbProducts, 'catProducts' => &$this->cat_products, 'hookExecuted' => &$hook_executed, )); // The hook was not executed, standard working if (!$hook_executed) { $this->context->smarty->assign('categoryNameComplement', ''); $this->nbProducts = $this->category->getProducts(null, null, null, $this->orderBy, $this->orderWay, true); $this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay); } $this->pagination((int)$this->nbProducts); // Pagination must be call after the last "getProducts" $this->addColorsToProductList($this->cat_products); foreach ($this->cat_products as &$product) { if (isset($product['id_product_attribute']) && $product['id_product_attribute'] && isset($product['product_attribute_minimal_quantity'])) { $product['minimal_quantity'] = $product['product_attribute_minimal_quantity']; } } $this->context->smarty->assign('nb_products', $this->nbProducts); } Edited October 26, 2016 by alain91 (see edit history) Link to comment Share on other sites More sharing options...
TiaNex Shopping Posted November 8, 2016 Share Posted November 8, 2016 just keep it, hook before-->display product list -hook after(hook modifier) 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