0

Im trying to override a controller from swissup/firecheckout location in my vendor folder

my di.xml is

<?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="Swissup\FieldManager\Controller\Adminhtml\Index\Save"
                type="My\Module\Controller\Adminhtml\Index\Save" />
</config>

and my controller is

namespace My\Module\Controller\Adminhtml\Index;

class Save extends \Magento\Framework\App\Action\Action
{
    public function execute()
    {
        die('sample die');
    }
}

but its still executing in Swissup\FieldManager\Controller\Adminhtml\Index\Save execute function. ive been debugging this one for quite some time now and dont know why its not working. i tried both etc/di.xml and etc/adminhtml/di.xml

1
  • Check modules My_Module enabled or not?
    – Amit Bera
    Mar 22, 2021 at 14:32

1 Answer 1

0

Try with below code, it should extend the class for which preference is defined

<?php

namespace My\Module\Rewrite\Swissup\FieldManager\Controller\Adminhtml\Index;

class Save extends \Swissup\FieldManager\Controller\Adminhtml\Index\Save
{
    public function execute()
    {
        die('sample die');
    }
}

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.