0

I would override this files in my custom theme (app/design/frontend/parent/MyCustomTheme/..)

vendor/magento/module-catalog-search/Model/Adapter/Mysql/Dynamic/DataProvider.php

vendor/magento/module-catalog-search/Model/Adapter/Mysql/Aggregation/DataProvider/SelectBuilderForAttribute.php

vendor/magento/module-catalog-search/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php

vendor/magento/module-catalog-search/Model/Adapter/Mysql/Filter/Preprocessor.php

How can i do? Thanks

1

No, You cannot override this file in theme under app/design folder

For that you need to create Module or Extension under app/code folder using preference

For example vendor/magento/module-catalog-search/Model/Adapter/Mysql/Dynamic/DataProvider.php

app/code/Vendor/Module/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\Adapter\Mysql\Dynamic\DataProvider" type="Vendor\Module\Rewrite\DataProvider"/>
</config>

Then create file app/code/Vendor/Module/Rewrite/DataProvider.php

<?php

declare(strict_types=1);

namespace Vendor\Module\Rewrite\Magento\CatalogSearch\Model\Adapter\Mysql\Dynamic;

class DataProvider extends \Magento\CatalogSearch\Model\Adapter\Mysql\Dynamic\DataProvider
{

}

if it make you confuse to do custom code then just copy DataProvider.php and paste it in Rewrite folder and then change namespace accordingly

Thanks Happy Coding

| improve this answer | |
  • Perfect man! Thanks! One more question please. When i create a custom column in table "catalog_product_index_price" and reindex my custom column is removed and i see error in my website because column not exist. My override is for this operation. How can I make my reindex not clear the column? Thanks – Jackom Nov 20 at 11:06
  • No idea but I think that happen because this column is kept for read/write operation for reindexing but you can try adding you column in both of this catalog_product_index_price, catalog_product_index_price_replica table use when catalog_product_price is reindexing. Might help you. But NOT RECOMMENDED – Nilesh Dubey Nov 20 at 11:38
  • Thanks man so i will try in local for the moment. Have a nice day! ;) – Jackom Nov 20 at 11:51

Your Answer

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

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