Magento: How to pass custom product attribute to order

Magento: How to pass custom product attribute to order

October 12, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: How to pass custom product attribute to order

Magento: Passing Custom Product Attributes to Order Items

In Magento CE 1.8.x, passing custom product attributes like qb_product_id from catalog to order items can be achieved through module configuration and observer setup. Here’s a step-by-step guide to solve this issue correctly.

Understanding the Current Setup

You’ve created a custom attribute named qb_product_id in the Magento admin interface under ‘Catalog -> Attributes -> Manage Attributes’. Additionally, you’ve set up an XML configuration file (config.xml) with fieldsets and events for converting quote items to order items while preserving your custom attribute.

The observer class (Observer.php) is designed to set the value of qb_product_id on a quote item when a product is associated with it during the checkout process. However, the issue lies in the lack of data persistence through the conversion process from quote to order.

Resolving the Data Persistence Issue

The key to solving this problem is ensuring that your custom attribute is mapped correctly across the stages of quoting and ordering.

Step 1: Modify config.xml for Order Item Fieldsets

You need to add a fieldset for the sales_order_item entity to map your custom attribute from quote item to order item. Update your config.xml:

<fieldsets>
    <sales_convert_quote_item>
        <qb_product_id>
            <to_order_item>qb_product_id</to_order_item>
        </qb_product_id>
    </sales_convert_quote_item>

    <!-- Add this fieldset -->
    <sales_convert_order_item>
        <qb_product_id>
            <to_quote_item>*</to_quote_item>
            <to_order_item>qb_product_id</to_order_item>
        </qb_product_id>
    </sales_convert_order_item>
</fieldsets>

Step 2: Ensure the Custom Attribute is Added to the Order Item

During the order creation process, Magento needs a way to add your custom attribute to the order item object. To do this:

  1. In ‘Sales -> Configuration -> Sales’, go to the ‘Quote’ section and ensure that under ‘Product Attributes’, you have added qb_product_id in the ‘Additional Settings’.

  2. After completing an order, verify if the qb_product_id is present in the order item data.

Best Practices: Extending Magento Functionality

When working with custom attributes in Magento, consider these best practices:

  • Always follow proper naming conventions for your module and files.
  • Keep your Observer classes light and focused on a single responsibility.
  • Test your changes thoroughly using Magento’s built-in testing framework or third-party tools like PHPUnit.
  • Use version control systems to track changes in your codebase.

Conclusion

To successfully pass custom product attributes from the catalog to order items, you need to ensure that the attribute is properly mapped across the entire checkout process—from quote to order. By following the steps outlined above and updating your config.xml file correctly, you can achieve this without needing to install the attribute on the sales_order_table directly.

Remember to always clear the cache and reindex after making changes to Magento’s XML configuration files. If you’re still facing issues or need further assistance with Magento development, feel free to explore our resources at Laravel Company.

Happy coding!

Checkout Catalog Extensions Admin

Our network