generateProductList
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.
Parameters
-
array
$bufferArray 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
$productsArray of product models.
-
\Contao\Template
$templateFrontend template instance that is used to render
mod_iso_productlisttemplate. -
\Isotope\Module\ProductList
$moduleInstance of
ProductListfrontend module.
Return values
Return the $buffer array.
Example
// 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;
}
}