Magento Bundle - Get attribute of option

Magento Bundle - Get attribute of option

September 7, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento Bundle - Get attribute of option

Customizing Magento Bundle Product Options: Displaying Size Attribute

Magento’s bundle product type provides a versatile way to group multiple products together for purchase. However, by default, the options displayed in the selection dropdown are based on the product name and price difference, which may not always be ideal.

In this post, we’ll explore how to modify the Magento select.phtml template under /template/bundle/catalog/product/view/options/type/bundle/option/select.phtml to display only the size attribute (pos_sizes) for each bundled option.

Understanding the Default Option Display

The default set-up uses the function echo $this->getSelectionTitlePrice($_selection, false) inside a foreach $_selections as $_selection loop. This produces an option label that combines the product name with its price difference in relation to the base product’s price.

For clothing products where each option represents a different size (and no additional pricing is applied), this default behavior isn’t optimal because it doesn’t clearly indicate the size attribute.

Objective: Display Only Size Attribute

You want to modify the options to simply show the value of the pos_sizes attribute for each bundled product. This will provide clearer information to customers about what they’re selecting.

Initial Attempts and Challenges

You’ve tried various methods to access the pos_sizes attribute, such as:

$_option->getAttributeText('pos_sizes')

$attribute = Mage::getModel('catalog/product')->getResource()->getAttribute("pos_sizes")

However, these attempts haven’t succeeded in displaying the size attribute values.

Available Variables in select.phtml

The top of select.phtml includes several predefined variables:

<?php $_option      = $this->getOption(); ?>
<?php $_selections  = $_option->getSelections(); ?>
<?php $_default     = $_option->getDefaultSelection(); ?>
<?php list($_defaultQty, $_canChangeQty) = $this->_getDefaultValues(); ?>

These variables represent the option object ($_option), the array of available selections ($_selections), the default selection, and some quantity-related settings.

Solving the Size Attribute Display

To display only the size attribute value for each option, you need to modify the foreach loop in select.phtml.

First, ensure that the pos_sizes attribute exists on your products with the following configuration:

  1. Navigate to Catalog > Attributes > Manage Attributes.
  2. Find or create an attribute called “Size/Position Sizes” (or any appropriate name).
  3. Set its Input Type to “Text Field”.
  4. Save and apply to existing products.

Next, update the foreach loop in select.phtml:

<?php foreach ($_selections as $_selection): ?>
    <option value="<?php echo $_selection->getSelectionId(); ?>" <?php if ($_option->getSelectionId() == $_selection->getSelectionId()) { ?> selected="selected"<?php } ?>>
        <!-- This is where we change the option label -->
        <?php
            // Get the corresponding product for this selection
            $product = Mage::getModel('catalog/product')->load($_selection->getProductId());

            // Retrieve and display the size attribute value
            echo $product->getAttributeText('pos_sizes');
         ?>
    </option>
<?php endforeach; ?>

In this updated code, we’re using Magento’s model to load the product associated with each selection. Then, we directly retrieve and echo the pos_sizes attribute text for that product.

Conclusion: Customizing Bundle Options

By following this guide, you’ve successfully modified the Magento select.phtml template to display only the desired size attribute (pos_sizes) for bundled products.

This customization improves the user experience by providing clear information about each option’s characteristics without relying on the default behavior of combining product names with price differences.

Remember that modifying core Magento templates is generally discouraged. It’s recommended to create a custom theme and copy select.phtml to your theme directory (app/design/frontend/[Package]/[Theme]/template/bundle/catalog/product/view/options/type/bundle/option/select.phtml) for better maintainability during updates.

For more advanced customization techniques, consider exploring Magento 2’s layout XML and block classes. Visit Laravel Company to learn about our professional Magento development services that can help you optimize your e-commerce platform further.

Catalog Themes Customers Pricing

Our network