The generateProductList
hook is called when the product list page is rendered.
It can be used to add custom context variables to the products list page, filter
rendered products or even to modify parsed HTML directly.
array $buffer
Array that holds information used to render each product in the list. Array items have the following shape:
[
'cssID' => '', // HTML "id" attribute
'class' => '', // HTML "class" attribute
'html' => '', // parsed product template (iso_reader_default.html5)
'product' => \Isotope\Model\Product // product model
]
array $products
Array of product models.
\Contao\Template $template
Frontend template instance that is used to render mod_iso_productlist
template.
\Isotope\Module\ProductList $module
Instance of ProductList
frontend module.
Return the $buffer
array.
// src/EventListener/Isotope/GenerateProductListListener.php
namespace App\EventListener\Isotope;
use Contao\Template;
use Isotope\Module\ProductList;
use Isotope\ServiceAnnotation\IsotopeHook;
/**
* @IsotopeHook("generateProductList")
*/
class GenerateProductListListener
{
public function __invoke(array $buffer, array $products, Template $template, ProductList $module): array
{
// Do something ...
return $buffer;
}
}