cancel
Showing results for 
Search instead for 
Did you mean: 

magento 2 model override Issue

magento 2 model override Issue

Right now I am trying to override the default class of Magento 2 due to some my custom requirement but couldn't succeed, don't know why what I have done wrong here. May be someone can help me to the right direction.

 

For this I have written this code in my system,

 

<preference for="Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection" type="COMPANY_NAME\MODULE_NAME\Model\ResourceModel\Fulltext\CatalogSearch\Collection"/> 

 

and I want to override this class,

 

Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection

 

This is my di.xml  [app\code\COMPANY_NAME\MODULE_NAME\etc\di.xml]

 

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">    
    <preference for="Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection" type="COMPANY_NAME\MODULE_NAME\Model\ResourceModel\Fulltext\CatalogSearch\Collection"/>   
</config>

Thanks,