0

I want to add some more parameters in _mapWppFieldset().

But I am not able to override this config class in magento2

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\Paypal\Model\Config" type="Vendor\Paypal\Model\Config" />

Vendor\Paypal\Model\Config.php

                <?php


             namespace Vendor\Paypal\Model;

         use Magento\Payment\Helper\Formatter;


       class Config extends \Magento\Paypal\Model\Config
      {
         protected function _mapWppFieldset($fieldName)
           {

    switch ($fieldName) {
        case 'api_authentication':
        case 'api_username':
        case 'api_password':
        case 'api_signature':
        case 'sales_api_signature':
        case 'sales_api_username':
        case 'sales_api_password':
        case 'payments_api_signature':
         case 'payments_api_username':
        case 'payments_api_password':
        case 'billing_api_signature':
         case 'billing_api_username':
        case 'billing_api_password':
        case 'account_api_signature':
         case 'account_api_username':
        case 'account_api_password':
        case 'sandbox_api_signature':
         case 'sandbox_api_username':
        case 'sandbox_api_password':
        case 'api_cert':
        case 'sandbox_flag':
        case 'use_proxy':
        case 'proxy_host':
        case 'proxy_port':
        case 'button_flavor':
        case 'button_type':
            return "paypal/wpp/{$fieldName}";
        default:
            return null;
        }
    }

  }
4
  • show your code, that you have tried?
    – Sohel Rana
    Commented Jan 29, 2019 at 5:32
  • @SohelRana please check Commented Jan 29, 2019 at 5:37
  • @RutveeSojitra, Have you tried the sequence in the module.xml? Commented Jan 29, 2019 at 5:50
  • yes, this is not issue of sequence issue is injecting class without constructor @AmitNaraniwal Commented Jan 29, 2019 at 5:53

1 Answer 1

0

Call parent constructor in you new file's constructor

public function __construct(
    \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
    \Magento\Directory\Helper\Data $directoryHelper,
    \Magento\Store\Model\StoreManagerInterface $storeManager,
    \Magento\Payment\Model\Source\CctypeFactory $cctypeFactory,
    \Magento\Paypal\Model\CertFactory $certFactory
) {
    parent::__construct($scopeConfig,$directoryHelper,$storeManager,$cctypeFactory,$certFactory);
}

Hope this will resolve your issue

2
  • I have checked parent file, there is a constructor in it, please update your module from composer, I think your module is outdated Commented Jan 29, 2019 at 6:01
  • What is the current version of you paypal module? Commented Jan 29, 2019 at 6:44

Your Answer

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

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