1. Magento 2.1.1
  2. Using Ubuntu/trusty64 vagrant-box, php7, apache

Steps to reproduce

  1. Add a new custom module
  2. Update etc/di.xml in your custom module

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">   
       <preference for="Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection" type="Sanimarkt\App\Model\ResourceModel\Fulltext\Collection" /> 
  3. Add new Collection.php file and override _renderFiltersBefore() method

    namespace Sanimarkt\App\Model\ResourceModel\Fulltext;
    class Collection extends \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection
      protected function _renderFiltersBefore()
        die('stopping here')
  4. clear cache

  5. Make a search request

Expected result

  1. The search request should stop and show 'stopping here' on the screen

Actual result

  1. Nothing happens the custom class

Sanimarkt\App\Model\ResourceModel\Fulltext\Collection.php is not executed.


2 Answers 2


It's opened on official repo - https://github.com/magento/magento2/issues/7734

Looks like it's not a bug for core team understanding. Yes, maybe, it's not a good idea, to override Fulltext\Collection, but I think it limitation, because you can not extend this class:

  • Plugins don't work because of a protected method
  • Events don't work, because no event is fired
  • Override doesn't work, because of virtual types
  • Override of virtual type doesn't work, because it breaks the search result

After that, you have to recompile.

bin/magento setup:upgarde

bin/magento setup:di:compile

Then check

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.