I created a small module which has a plugin. This plugin must exchange a method with my own.

But my plugin is never being called.

I have been staring at this for a few hours. Can anyone help me with this?


<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider">
        <plugin disabled="false"



namespace Custom\ConfigurableChildSearch\Plugin;

class DataProvider
     * @param \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider $subject
     * @param \Closure                                                          $proceed
     * @param                                                                   $indexData
     * @param                                                                   $productData
     * @param                                                                   $storeId
    public function aroundPrepareProductIndex(\Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider $subject, \Closure $proceed, $indexData, $productData, $storeId)


2 Answers 2


Things to try when your plugins aren't being called.

Inserting die('loaded plugin') temporarily in your plugin and die('loaded method') in the original method (or using debugger breakpoints) is a good idea.

1: Clear the generated files (fast, good for a quick check if your module has already been registered with #2)

rm -rf generated/*

2: Clear all caches and generated dirs, and register new modules. (slow, but basically refreshes everything)

 php bin/magento setup:upgrade        

3: Regenerate the di code. (slow, but can find issues in your code that the other methods don't)

php bin/magento setup:di:compile
php bin/magento cache:flush

Usually, #1 works, if not, try #2, then #3. If none of those work, check that your module's di.xml lines up with your modules (in the original post, it seems to).

Double-check that filepaths correspond with class names, and that case matches.

Official documentation for plugins is here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html


Did you run setup:di:compile after defining your plugin?

Take a look at Magento 2 Docs Code Compiler

and at: Magento2 - setup:di:compile + Magento 2: When should I run which commands?

According to that you have to run that command if you changed something in your di.xml files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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