0

I need to override this class

Magento\CatalogSearch\Model\ResourceModel\Fulltext
Collection

in my custom module. I have created di.xml in etc/frontend folder.

and created the class and overridden the method. This my code:

di.xml

    <preference for="Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection" type="Daiva\Customsearch\Model\Resource\Fulltext\Collection"/>
</config>

Class:

namespace Daiva\Customsearch\Model\Resource\Fulltext;

/**
 * Fulltext Collection
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 */
class Collection extends \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection {

    /**
     * @inheritdoc
     */
    protected function _renderFiltersBefore() {
echo "Daiva";
        exit;
        $result = parent::_renderFiltersBefore();
        $this->_totalRecords = null;
        return $result;
    }

}

But it is not working. Did i make any mistake?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.