Hi,
I'm developping a module to display a tag on a product but only if the product has the "HOT" feature equals 1.
Here's my code:
public function hookDisplayProductPriceBlock($params)
{
$product = $params['product'];
if ($product->HOT == 1) {
return $this->display(__FILE__, 'views/templates/hook/hotproduct.tpl');
}
}
It doesn't show anything on a product with the HOT attribute at 1. If I remove the condition, it does show!
I also tried that:
public function hookDisplayProductPriceBlock($params)
{
$product = $params['product'];
// Obtener las características del producto
$features = $product->getFrontFeatures($this->context->language->id);
// Buscar la característica "HOT" entre las características del producto
$hotValue = null;
foreach ($features as $feature) {
if ($feature['name'] === 'HOT') {
return $this->display(__FILE__, 'views/templates/hook/hotproduct.tpl');
break;
}
}
//if ($product->HOT == 1) {
// return $this->display(__FILE__, 'views/templates/hook/hotproduct.tpl');
// }
}
but give me this error: PHP Fatal error: Uncaught Error: Call to undefined method PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductLazyArray::getFrontFeatures()
Any idea?