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 Accept as Solution!
Magento Extension Developer | Facebook | Twitter
2 REPLIES

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

Hi @SanjayJethva,

 

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.

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

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 Accept as Solution!
Magento Extension Developer | Facebook | Twitter