Remove Price filter and sorter
Description
To remove Price filter and sorter in frontend_product_search_datagrid
it is necessary to create an EventListener to edit the datagrid
Services
# src/Kiboko/Bundle/FooBundle/Resources/config/services.yml
services:
kiboko_foo.event_listener.frontend.product_price_datagrid:
class: Kiboko\Bundle\CorporateProductBundle\EventListener\FrontendProductRemovePriceDatagridListener
tags:
- { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.frontend-product-search-grid, method: onBuildBefore }
Datagrid listener
<?php
# src/Kiboko/Bundle/FooBundle/EventListener/FrontendProductRemovePriceDatagridListener.php
namespace Kiboko\Bundle\FooBundle\EventListener;
use Oro\Bundle\DataGridBundle\Event\BuildBefore;
use Oro\Bundle\PricingBundle\EventListener\FrontendProductPriceDatagridListener;
class FrontendProductRemovePriceDatagridListener
{
/**
* {@inheritDoc}
*/
public function onBuildBefore(BuildBefore $event)
{
$config = $event->getConfig();
$config->removeSorter(FrontendProductPriceDatagridListener::COLUMN_MINIMAL_PRICE_SORT);
$config->removeFilter(FrontendProductPriceDatagridListener::COLUMN_MINIMAL_PRICE);
}
}