Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top