0

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\Address\FormPost">
        <plugin name="yourCompanyYourModuleControllerProductView" type="namespace\Customer\Plugin\FormPost" sortOrder="1"/>
    </type>
</config>

Plugin/FormPost.php

<?php
namespace namespace\Customer\Plugin;
class FormPost {
    public function afterExecute(\Magento\Customer\Controller\Address\FormPost $subject)
    {
        $temp = '';
        $te = '';
    }
}

But code is not being called.. any one has idea what could be possible reason for this? Thanks

5
  • Any error are throw? – Rakesh Jesadiya Feb 14 '17 at 6:25
  • its not throwing any error too... its just not going in Plugin code... I put breakpoint in plugin method... – sohaib Feb 14 '17 at 22:49
  • Make sure your module name is the same in your registration.php file as it is in your etc/module.xml file. This caused an issue for me. – dmatthew Feb 15 '17 at 6:32
  • It was caching issue.... thanks for ur comments :) – sohaib Feb 15 '17 at 23:04
  • How do you check if the plugin is getting called?! – Black Nov 4 '20 at 14:47
0

You have forgot to pass second argument to function, pass $result as second argument,

$result is original method return value.

<?php
namespace namespace\Customer\Plugin;
class FormPost {
    public function afterExecute(\Magento\Customer\Controller\Address\FormPost $subject,$result)
    {
        $temp = '';
        $te = '';
        return 'Test '.$result;
    }
}
1
  • tried it... it did not work... – sohaib Feb 14 '17 at 22:49
0

My case was forget to Di Compile

php bin/magento setup:di:compile

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.