cancel
Showing results for 
Search instead for 
Did you mean: 

How to Override Payment Helper Data Method Magento 2?

How to Override Payment Helper Data Method Magento 2?

Hi

I am trying to override Magento Payment Helper data in my extension to restirct payment method but its not working.

I have override by using preference method.

Here is the below code I have put below code in app/code/Demo/PaymentTest/etc/di.xml

<preference for="Magento\Payment\Helper\Data" type="Demo\PaymentTest\Helper\Data" />


Here is My Helper code

<?php
namespace Demo\PaymentTest\Helper;
class Data extends \Magento\Payment\Helper\Data
{
    public function getStoreMethods($store = null, $quote = null)
    {
    }
}


I am trying to override getStoreMethods method in my helper but its not calling it.

Can you please tell me where i am doing wrong?

Thanks in advnace.

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.
2 REPLIES 2

Re: How to Override Payment Helper Data Method Magento 2?

Hi @Sanjay Jethva,

 

This isn't a solution but why not using Plugins? http://devdocs.magento.com/guides/v2.1/extension-dev-guide/plugins.html

It will be a better approach to handle a modification to core modules.

Re: How to Override Payment Helper Data Method Magento 2?

Hello @Damian Culotta,

Thanks for your answer. I have tried plugins but file is calling but method is not calling.

Please share a code.

 

Thanks in advnace.

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.