I set a session variable through ajax request like in checkout page
Mage::getSingleton('customer/session')->setMyValue($value_from_post_data);
The above is set in a controller of a One Page Checkout module.
I have an event observer which observes checkout_onepage_controller_success_action
here, when I access the session, I don't find my_value the session variable I created.
Note: The session ids are same. No change in them. After the session value is set, I printed the whole session data to confirm, the setMyValue
created my_value in the session.
So the ajax request has done its job. It has set the variable But the observer picks up old session data. Why is this happening, give me a work around
Best Answer
As you have said that your form is exit in Checkout step then we can set field value at Quote Object and then you can
get this quote variable value from order
at success page which fill you requirement.Step1: Create new field at Sale Quote table and Order table using installer
Step2: On your Custom controller save this field to new quote field
Step3: We have used copy field logic for copy Quote field value to Order field value.
Please Study:about this
Step4: Then you can easy get this field value from Order object
Full Module:
Step1: Create Module at
app/code/local/Stackexchange/Magento51524/etc/config.xml
code is
Step2: Create Installer file at
app/code/local/Stackexchange/Magento51524/sql/salesattribute1420712691_setup/mysql4-install-0.1.0.php
And code is:
Step3: Create
Helper class
atapp/code/local/Stackexchange/Magento51524/Helper/Data.php
Code is
Step4: Observe file : at
app/code/local/Stackexchange/Magento51524/Model/Observer.php
A nd code
Step5: Create
Stackexchange_Magento51524.xml
which used for Module config at app\etc\modules\Code is
Step:On your submit controller add this code for set the field to new quote fields