Chapters Close

How to override reorder functionality in Magento 2 by disabling core plugin?

Hello readers, how’s your Magento development going, I hope it’s going fine.

You must have landed this post, because you are looking for solutions on how you can override reorder functionality in Magento 2 by disabling core plugin. No worries I will be guiding you through this solution.

So first of all, I will show you from the last two days the things that I have done to override the reorder functionality in Magento 2, then I will give you the final solutions.

Steps I took to override the reorder functionality in Magento 2

1. To override the functionality, I created around plugin which didn’t work because one of core magento extensions was already used around plugin for that and they are not using callable($proceed) function in around plugin so that the function process terminated there.

2. Tried to override core magento extension plugin files through preference which didn’t work because we can’t override the core plugins through preference.

3. Tried to change the sequence of core magento extension through custom extension and tried to load custom extension first but didn’t work because we can’t load core extension after custom extension. We can add dependency in our custom extension but that dependency calls core extension first.

4. Finally I disabled core magento extension plugin through custom extension and then call my custom plugin after it. This trick works like a charm.
(Please find the code below)

Please create a custom extension and write the below code in etc/di.xml.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Sales\Controller\Order\Reorder">
        <plugin name="replaceQuoteItems" type="Magento\NegotiableQuote\Plugin\Sales\Controller\Order\ReorderPlugin" disabled="true" />
        <plugin name="replaceOrderItem" type="VendorName\ModuleName\Plugin\Sales\Controller\Order\ReorderPlugin" />
    </type>
</config>

Now, Please run the DI compile process: php bin/magento setup:di:compile

I hope this post can save someone’s valuable time and help him/her to understand the basic concepts of the Magento 2 framework.

Thanks for reading and comment down if you have any query, will be more than happy to help you. You can also follow us on twitter and share your queries there as well.

Speak your Mind

Post a Comment

Got a question? Have a feedback? Please feel free to leave your ideas, opinions, and questions in the comments section of our post! ❤️

* This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Thank you for your feedback

Comments (1)

  1. Hi I have been tried the same way in my custom module but its redirects to the abstract controller under the controller folder of module-sales in vendor . How can I prioritize the my module needs to load first without vendor class. Can u please help us on the scenario to execute the my defined reorder class.

    Reply

Grow your online business like 4,720 subscribers

    * This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
    envelope

    Thank You!

    We are reviewing your submission, and will be in touch shortly.