I need to change one attribute when a product is sold, when the order is completed, I guess I can hook something/somewhere but I’ve no idea where/what.
thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If your question is asked “the magento way”, when you say “order is completed”, this means that its status is “complete”. An order with “complete” status has been ordered on the frontend site, then invoiced and shipped from the admin.
My answer is based on this terminology, thus giving you clues to change a product attribute once an order has been completed (again, in the magento way).
Coding the whole thing for you is not good help and is very long, so here is the path (in my opinion) 🙂
Create a module
(Google is your friend for that)
Attach an observer to this module and make it observe the event “sales_order_save_after”
(Google is your friend for that)
In the observer file / method, retrieve the order and its status
If order status is “completed”, create a foreach that updates the attribute you want for all items
This will give the same attribute value to all products. In this example, all products for a completed order will be renamed to ‘Sold Product’.
This should be enough to put you on the right track.