3

i am trying to override \Magento\Payment\Model\Method\AbstractMethod class method assignData method in my custom class but its not working.

Model class

 namespace Vendor\Module\Model;
class PaymentCustomData extends \Magento\Payment\Model\Method\AbstractMethod {

    public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Payment\Model\Method\Logger $logger, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = array()) {
        die(__METHOD__);exit;
        parent::__construct($context, $registry, $extensionFactory, $customAttributeFactory, $paymentData, $scopeConfig, $logger, $resource, $resourceCollection, $data);
    }
    public function assignData(\Magento\Framework\DataObject $data) {
        var_dump($data->getData());
        exit;

     return $this;
    }

}

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\Payment\Model\Method\AbstractMethod" type="Vendor\Module\Model\PaymentCustomData" />
    </config>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.