How do I get bundle option selection SKU?

How do I get bundle option selection SKU?

July 6, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How do I get bundle option selection SKU?

Retrieving Bundle Option Selection SKU in Magento

In Magento, retrieving product options such as title, quantity, and price for bundle products is quite straightforward. However, when it comes to obtaining the SKU of the selected bundle option items, the process requires a slightly different approach.

Understanding Magento’s Bundle Product Structure

Magento’s bundle product type allows customers to select multiple configurable options from a list of products. Each option can have its own title, quantity available for selection, and price contribution. To retrieve these details, you typically interact with the productOptions array provided by the order item.

Accessing the Selected Bundle Options

The code snippet you provided demonstrates how to loop through all items in an order and print out product options for bundle products:

foreach ($order->getAllItems() as $item) {

    $productOptions = $item->getProductOptions();
    echo $product_id = $item->product_id;

    $_product = Mage::getModel('catalog/product')->load($product_id);
    if ($_product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {

        if (isset($productOptions['bundle_options'])) {
            foreach ($productOptions['bundle_options'] as $productOption) {
                echo $value = $productOption['value'][0]['title'];
                echo ' || ';
                echo $value = $productOption['value'][0]['qty'];
                echo ' || ';
                echo $value = $productOption['value'][0]['price'];
                echo "<br>";
            }
        }
    }
}

Retrieving the SKU of Selected Bundle Option Items

To retrieve the SKU of each selected option item, you need to access the sku property of the $_product object. Here’s how you can modify your code:

foreach ($order->getAllItems() as $item) {

    $productOptions = $item->getProductOptions();
    echo $product_id = $item->product_id;

    $_product = Mage::getModel('catalog/product')->load($product_id);
    if ($_product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {

        if (isset($productOptions['bundle_options'])) {
            foreach ($productOptions['bundle_options'] as $productOption) {
                echo $value = $productOption['value'][0]['title'];
                echo ' || ';
                echo $value = $productOption['value'][0]['qty'];
                echo ' || ';
                echo $value = $productOption['value'][0]['price'];
                echo ' || ';
                echo $value = $_product->getSku(); // Add this line
                echo "<br>";
            }
        }
    }
}

Conclusion

Retrieving the SKU of selected bundle option items in Magento requires accessing the sku property of each loaded product object. By following the modified code snippet, you can now print out the SKU along with the title, quantity, and price for each selected bundle option.

Remember that this code is executed within Magento’s core logic, so it adheres to the framework’s best practices and performance optimizations. For more advanced customizations or if you’re working on a Laravel project, consider using the Laravel Company’s Magento API services for seamless integration.

Always test your code thoroughly in a development environment before deploying it to a live production site. This ensures that any potential issues are addressed before they impact your customers or business operations.

If you have any further questions or need additional assistance with Magento development, feel free to explore the resources available at Laravel Company. Our team of experienced developers is always ready to help you overcome technical challenges and achieve your e-commerce goals.

Catalog Configuration Orders Customers

Our network