سؤال

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

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top