1

I have created a custom attribute that shows on the product detail page like colour and size attribute, I want them to be saved on order placement so that I can retrieve them in the order information, order email.

I am not sure how to achieve this, Right now I am displaying the custom attribute of the product in order but the value changes when I change the value in the product backend, I must show the value which is saved during order placement.

1
  • Are you saving that custom attribute value to order item (sales_order_item) table? if yes, then you can get that easily wherever you want. Dec 3, 2018 at 6:24

1 Answer 1

0

To achieve this, you have to follow the below sub-task to achieve this

  1. Create a custom module
  2. Add an extension attribute that contains your custom attribute
  3. Create an observer/plugin class and save the product attribute's value while place order event will trigger

You can also add just a new table column to the sales_order_item table instead of creating an extension attribute. But note that using an extension attribute is the better way from a maintainability and compatibility standpoint as you do not modify a Magento core table.

The below links will help you.

You can follow the below tutorial to create a new module

how to add extra field in 'order_item' table when product order success?

1
  • Thank you is there a blog containing example
    – fernandus
    Dec 7, 2018 at 19:15

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.