0

I have an Api call in observer function.

From there, I got a order details.I need to sent that order id into the corresponding controller. How I get this order id value into my controller?

Can i set it as a session value from observer to controller?

4
  • Pass that order id parameter to your controller function Commented Nov 7, 2017 at 10:59
  • How can I pass the order id to controller?
    – ams
    Commented Nov 7, 2017 at 11:51
  • Can you specify how you call controller function from Observer? Commented Nov 7, 2017 at 12:06
  • <controller_action_postdispatch_batch_controller_batch> <observers> <batchcode> <class>Bridge_Batchcode_Model_Observer</class> <method>saveInvoiceOrders</method> </batchcode> </observers> </controller_action_postdispatch_batch_controller_batch>
    – ams
    Commented Nov 7, 2017 at 12:32

1 Answer 1

0

I am assuming you already have some knowledge of setting up the observer and controller, but let me know if that is not the case, and I will expand my answer.

In the observer (app/code/local/Package/Vendor/Model/Observer.php):

if($session = Mage::getSingleton('customer/session')) {
    $session->setData("some_variable_name");
}

In the controller (path will vary):

if($session = Mage::getSingleton('customer/session')) {
    $passed_value = $session->getData("some_variable_name");
}
// do something with $passed_value
3
  • I have used this code but it's not getting in my controller. session successfully set in observer file but visible in controller.
    – ams
    Commented Nov 8, 2017 at 3:34
  • My controller is in front end and model in admin side.
    – ams
    Commented Nov 8, 2017 at 4:43
  • @MarySebastian, you can try using Mage::getSingleton('core/session'), which is not specific to the customer. There is more information about session types HERE
    – mtr.web
    Commented Nov 8, 2017 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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