3

Looking at the Bundled product template select.phtml, I cannot figure how to pull in the attribute options in the 'dropdown' select input type that distinguishes between children (Simple products) rather than the Product Name (by default). In Configurable products this is the super_configurable_attribute so what I'm looking to do is something like a super_bundle_attribute which displays the relative attribute option.

app/design/frontend/rwd/default/template/bundle/catalog/product/view/type/bundle/option/select.phtml

How I would need to change this in Magento CE 1.9?

  • There is no thing such as attributes related to bundle products, you can bundle anything in a bundle option independent from attributes. – Fabian Schmengler Mar 22 '15 at 14:49
  • 1
    You are incorrect fschmengler, the Parent > Child relationship is derived from 'attributes' - so the origination of this question/request wasn't necessarily programmatic but rather how to get the data to display in such a way that more resembles a super_configurable_attribute...in this case, I have the parent > child relationship but also have an additional child (demo product) I don't want included in the dropdown. – Will Bebee Mar 23 '15 at 2:13
  • Looks like I misunderstood you then, and you were talking about the bundle options, which are technically not attributes and, more important, do not have names per simple product, they contain only relations to the simple products. Maybe the question will be more clear if you give an example. – Fabian Schmengler Mar 23 '15 at 6:20
  • Here's an example of in the cart: take.ms/GsgtQ - and here's the product page dropdown: take.ms/iChcQ - – Will Bebee Mar 23 '15 at 14:34
0

I actually played around with this for a while and thanks to this post: Magento Bundle - Get attribute of option I was able to figure this out, the code change was from (native 1.9.1 select.phtml template):

<?php echo $this->getSelectionTitlePrice($_selection, false) ?></option>

to

<?php $bundledsize = Mage::getModel('catalog/product')->load($_selection->getId())->getAttributeText('your_custom_attribute'); echo $bundledsize; ?>

  • Best Magento Magento practices would be using 'getSingleton' rather than using 'getModel', from a performance perspective > getModel is bad practice, the end result is: <option value="<?php echo $_selection->getSelectionId() ?>"<?php if ($this->_isSelected($_selection)) echo ' selected="selected"' ?><?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>><?php $bundledsize = Mage::getSingleton('catalog/product')->load($_selection->getId())->getAttributeText('your_custom_attribute'); echo $bundledsize; ?></option> – Will Bebee Mar 22 '15 at 12:41
  • No, getSingleton would only result in unwanted side effects and not resolve the best practice violations to not load a model in a template and especially to not load a model in a loop. Using getSingleton covers the violation from code sniffers at most, but doesn't solve the problem. – Fabian Schmengler Mar 22 '15 at 14:46
  • Hi fschmengler, then what would you use? – Will Bebee Mar 23 '15 at 2:10
  • And while I'm at it....how would I get this custom_attribute that I successfully called in the template to show in the cart as shown here: take.ms/GsgtQ - – Will Bebee Mar 23 '15 at 2:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.