Reputation: 775
I need to store additional data to PHP $_SESSION
, but I need to do that while Magento order is being saved to database. I am saving additional payment method information which is not required to be stored in DB and is not explicitly connected to order. Could you please give me a little bit of background for that process?
When
is it being saved?what class
is it done?Upvotes: 0
Views: 892
Reputation: 78
Have you tried to use Magento events? It is even recommended to use events instead of (what I guess you want to) editing core Magento files. In this case you could use two events, depending on your needs.
sales_order_save_after
or
sales_order_save_before
They basically are what they say, with first one you will be able to modify order before saving it to database and second one will let you modify the order which will be already saved. About Magento observers (if you are not familiar with them), answer here: https://magento.stackexchange.com/questions/41277/how-to-create-an-new-observer-on-the-event-catalog-product-save-before should be enough for you. Of course, remember to observer the event that you want to. Then inside your observer method you will just have to use something like this:
$order = $observer->getEvent()->getOrder();
and do what you want to with this order (with event _after remember to ->save() order when you will change it.
Upvotes: 1