0

I try to create a plugin and getting following error

plugin does not exist error

Loginpost/Redirect/frontend/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">
  <type name="\Magento\Customer\Controller\Account\LoginPost">
    <plugin name="loginpost_redirect_loginpostplugin" type="\LoginPost\Redirect\Plugin\LoginPostPlugin" sortOrder="1" />
  </type>
</config>

Loginpost/Redirect/Plugin/LoginPostPlugin.php

<?php

namespace Loginpost\Redirect\Plugin;

class LoginPostPlugin
{
    public function afterExecute(
        \Magento\Customer\Controller\Account\LoginPost $subject,
        $result)
    {
        $result->setPath('/checkout');
        return $result;
    }

}
  • i think issue of namespace.... in your path vendor name is "Loginpost" and define in di.xml "LoginPost" – Rk Rathod Aug 13 '19 at 11:21
1

I think Issue Is In Your Name Space..

In your Path module name is Loginpost and define in di.xml LoginPost

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
  <type name="\Magento\Customer\Controller\Account\LoginPost">
    <plugin name="loginpost_redirect_loginpostplugin" type="\Loginpost\Redirect\Plugin\LoginPostPlugin" sortOrder="1" />
  </type>
</config>
0

Replace your code in di.xml with following

<?xml version="1.0"?>
   <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
   <type name="Magento\Customer\Controller\Account\LoginPost">
      <plugin name="loginpost_redirect_loginpostplugin" type="LoginPost\Redirect\Plugin\LoginPostPlugin" sortOrder="1" />
   </type>
</config>

Not the answer you're looking for? Browse other questions tagged or ask your own question.