0

Hi I'm using very nice plugin 'login-as-customer' by magefan. I'd like to override an execute method of login-as-customer. this is first time to try overriding third pirty's controller so I stuck now.

I put files like this and expect to ignite Plugin/Login but does not. how can i solve this?

MyModule
├── Plugin
│   └── Login.php
├── etc
│   ├── di.xml
│   └── module.xml
└── registration.php

di.xml

<?xml version="1.0"?>                                                                                                                                                                             
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
   <type name="Magefan\LoginAsCustomer\Controller\Login\Index">
        <plugin name="intercept_login" type="MyCompany\MyModule\Plugin\Login" sortOrder="1"/>
    </type>
</config>

namespace MyCompany\MyModule\Plugin;

class Login
{
    /**
     * Login as customer action
     *
     * @return \Magento\Framework\Controller\ResultInterface
     */

    public function aroundExecute()
    {
        echo "here";
        die;
    }
}

finary, i want to inject an admin info into customer session. after i could solve this problem, i gonna write script in the aroundExceute.

5
  • 1
    Have you executed di compile & cleared cache ? Oct 16 '20 at 4:52
  • thanks. i forgot to write it.i did setup:upgrade, setup:di:compile, cache:clean.
    – grandan
    Oct 16 '20 at 7:05
  • You might need to pass original controller instance in to public function aroundExecute() argument. Oct 16 '20 at 7:28
  • It works! I really appreciate you.
    – grandan
    Oct 16 '20 at 15:35
  • Great, please mark answer as right. if that helps. Oct 17 '20 at 4:32
0

You might need to pass original controller instance in to public function aroundExecute() argument.

1
  • Okay. I remove the flag.
    – Jarnail S
    Oct 17 '20 at 4:39

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.