0

I am trying to find controller action of module for below Observer code, so that i can see those action names in log file : called_action_names.log , its displaying those names in log files.

issue : along with this its displaying those names in site & now its not saving the uploaded image in site once we click on "save design" button.

you can see text catalog_product_view in top of the page

public function onControllerActionPredispatch($observer)
    {
      Mage::log($observer->getEvent()->getControllerAction()->getFullActionName(), Zend_Log::DEBUG, 'called_action_names.log');
        if (
            $observer->getEvent()->getControllerAction()->getFullActionName() == 'example_amasty_createProduct' &&
            !Mage::getSingleton('customer/session')->isLoggedIn()
        ) {
            Mage::getSingleton('customer/session')->setAmastyExampleCustomProductInfo(
                $observer->getEvent()->getControllerAction()
                    ->getRequest()->getPost('Amasty')
            );
        }
        else if (
            Mage::getSingleton('customer/session')->isLoggedIn() &&
            Mage::getSingleton('customer/session')->getAmastyExampleCustomProductInfo()
        ) {

        }

     echo $observer->getEvent()->getControllerAction()->getFullActionName();
    }

   }

config.xml

<controller_action_predispatch>
            <observers>
                <Amasty_Example>
                    <class>example/observer</class>
                    <method>onControllerActionPredispatch</method>
                </Amasty_Example>
            </observers>
</controller_action_predispatch>

when i replace line : <class>example/observer</class> by <class>my_module/observer</class> , it dont show any issue. but real module name is "example".

3

You need to remove echo from your observer code.

public function onControllerActionPredispatch($observer)
{
  Mage::log($observer->getEvent()->getControllerAction()->getFullActionName(), Zend_Log::DEBUG, 'called_action_names.log');
    if (
        $observer->getEvent()->getControllerAction()->getFullActionName() == 'example_amasty_createProduct' &&
        !Mage::getSingleton('customer/session')->isLoggedIn()
    ) {
        Mage::getSingleton('customer/session')->setAmastyExampleCustomProductInfo(
            $observer->getEvent()->getControllerAction()
                ->getRequest()->getPost('Amasty')
        );
    }
    else if (
        Mage::getSingleton('customer/session')->isLoggedIn() &&
        Mage::getSingleton('customer/session')->getAmastyExampleCustomProductInfo()
    ) {

    }
}
  • Its really strange that we can display in frontend with help of observer code, i thought we can do it by only template files..... Thanks a lot..... – Baby in Magento Apr 7 '17 at 6:51

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.