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);
}