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 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 . Commented Nov 10, 2016 at 13:43
  • 1
    convert your comment into your answer @KhoaTruongDinh so charan can accept it :) 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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.