I want to call catalog_product_collection_load_after event in magento 2
How can i call that event in my custom module in magento 2?
EDIT
Filter is not working
events.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="catalog_product_collection_load_before">
<observer name="product_filter" instance="Custom\Example\Observer\Productfilter" />
</event>
Productfilter.php
namespace Custom\Example\Observer;
use Magento\Framework\Event\ObserverInterface;
class Productfilter implements ObserverInterface
{
public function execute(\Magento\Framework\Event\Observer $observer)
{
$observer = $observer->getEvent()->getCollection();
$observer->addAttributeToFilter('name_day',array(
array('finset'=> array("Fri")),
));
return $this;
}
}
name_day
exists in the table. Can you also echo the query? ($collection->getSelectSql(true)
)