0

I want to override abstract class Magento\Sales\Controller\Adminhtml\Order\Create of the below method

protected function _processActionData($action = null){

 }

I have tried using preference but it is not working.

Can anybody help me with this?

1

Use a preference to tell Magento which class to use in place of the vendor class Magento\Sales\Controller\Adminhtml\Order\Create (I suppose you're creating a module named Module at the path app/code/Custom/Module):

<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectMamager/etc/config.xsd">
    <preference type="Custom\Module\Controller\Adminhtml\Order\Create" for="Magento\Sales\Controller\Adminhtml\Order\Create"/>
</config>

Then, create the file app/code/Custom/Module/Controller/Adminhtml/Order/Create.php:

<?php
declare(strict_types=1);

namespace Custom\Module\Controller\Adminhtml\Order;

use Magento\Sales\Controller\Adminhtml\Order\Create as MagentoCreate;

abstract class Create extends MagentoCreate
{
    protected function _processActionData($action = null){
        // here your code
    }
}

Finally, run bin:magento setup:upgrade.

1
  • it is not working hay you checked? – Chirag Patel Dec 15 '20 at 5:38
0

Preferences don't work for abstract classes because the abstract classes are never instantiated. But you can use preferences for the classes that extend the Magento\Sales\Controller\Adminhtml\Order\Create class.

1
  • Thanks for the answer. can you share an example of it? – Chirag Patel Dec 4 '20 at 9:49

Your Answer

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

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