0

I am trying to override customer/account/editpost controller.

I am getting error

Recoverable Error: Argument 1 passed to Magento\Customer\Controller\Account\EditPost::__construct() must be an instance of Magento\Framework\App\Action\Context

I created di.xml file at location module/etc/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\Customer\Controller\Account\EditPost" 
     type="Namespace\Modulename\Controller\Index\Editpost" />
</config>

and controller Controller\Index\Editpost.php

namespace Namespace\Modulename\Controller\Index;

class Editpost extends \Magento\Customer\Controller\Account\EditPost
{

    public function execute()
    {

        echo "asdasdsda"; die;
        return parent::execute();
    }


}
9
  • Remove var/generation and try again. Commented Nov 10, 2016 at 13:32
  • still not working whole site broke
    – chin
    Commented Nov 10, 2016 at 13:39
  • Try to refresh the page many times? Commented Nov 10, 2016 at 13:40
  • I want to override customer/account/editpost controller. I refreshed site many time .
    – chin
    Commented Nov 10, 2016 at 13:43
  • 1
    convert your comment into your answer @KhoaTruongDinh so charan can accept it :)
    – Keyur Shah
    Commented Nov 10, 2016 at 15:12

1 Answer 1

0

-- The main reason is that the Controller classes are generated (automatically) in var/generation folder. Please, delete this folder.
-- Make sure the Magento Cache is clear.

Note: May we need to refresh the browser again again because the generation classes need time to re-generate.

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.