Question

So a module installed via composer lives in vendor/module, and I'd like to change its etc/di.xml from this:

    <virtualType name="customCategoryCollection" type="Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection">
        <arguments>
            <argument name="searchRequestName" xsi:type="string">catalog_view_container</argument>
        </arguments>
    </virtualType>

To this:

    <virtualType name="customCategoryCollection" type="Custom\Module\Model\ResourceModel\Fulltext\Collection">
        <arguments>
            <argument name="searchRequestName" xsi:type="string">catalog_view_container</argument>
        </arguments>
    </virtualType>

Is that possible without editing the vendor/module di.xml?

Was it helpful?

Solution

You can do this in one of your custom modules, in the di.xml add the code that you need

<virtualType name="customCategoryCollection" type="Custom\Module\Model\ResourceModel\Fulltext\Collection">
    <arguments>
        <argument name="searchRequestName" xsi:type="string">catalog_view_container</argument>
    </arguments>
</virtualType>

Or you can preference your original class to your class

<preference for="Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection"
            type="Custom\Module\Model\ResourceModel\Fulltext\Collection" />

just make sure your module depends on the original vendor module

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top