Skip to content

How to remove the Deprecated property of __construct from Abstract Class using overriding or any other way

Error

main.ERROR: Deprecated Functionality: Creation of dynamic property
MagiccartMagicproductControllerAdminhtmlProductIndexInterceptor::$_resultRedirectFactory
is deprecated in
vendor/magiccart/magicproduct/Controller/Adminhtml/Action.php on line
78

Class namespace MagiccartMagicproductControllerAdminhtmlAction

abstract class Action extends MagentoBackendAppAction  {      
public function __construct(
        MagentoBackendAppActionContext $context,
    ) {
        parent::__construct($context);
        $this->_resultRedirectFactory = $context->getResultRedirectFactory();
    }

Class MagiccartMagicproductControllerAdminhtmlProductIndex

class Index extends MagiccartMagicproductControllerAdminhtmlAction
{
    /**
     * @var MagentoFrameworkViewResultPageFactory
     */
    public function execute()
    {
        if ($this->getRequest()->getQuery('ajax')) {
            $resultForward = $this->_resultForwardFactory->create();
            $resultForward->forward('grid');

            return $resultForward;
        }

        $resultPage = $this->_resultPageFactory->create();

        return $resultPage;
    }
}

Current Solution
I have tried to override it using preference and than remove the line 78

$this->_resultRedirectFactory = $context->getResultRedirectFactory();

but still it is showing the same error (But if i do direct change in code this issue get fixed)

class CustomMagicproductControllerAdminhtmlCustomAction**

    abstract class CustomAction extends MagiccartMagicproductControllerAdminhtmlProduct
{

Another way

<type name="MagiccartMagicproductControllerAdminhtmlAction">
    <arguments>
        <argument name="_resultRedirectFactory" xsi:type="string">nothing</argument>
    </arguments>
</type>

But Nothing works and same error appearing again