Hello, I read a lot of posts about this, and so far it has not fully worked.
For instance; Attribute 1 = shoes and attribute 2 = color of shoes. Both are in the drop-down list, and I would like to indicate all the possible attribute colors for each product on the category pages.
Problem: when I test the code, it will display only the first color of the shoe, and not all posibilites. What am I doing wrong here?
Here are 3 examples of what I have. All code works, but only shows the first color of the attribute. Example 1:
<?php foreach ($_productCollection as $_product): ?> <?php echo $_product->getMyAttribute() ?> <?php echo $_product->getAnotherCustomAttribute() ?> <?php echo $_product->getAttributeText('shoecolor') ?> <?php endforeach?>
Example 2
<?php echo $_product->getResource()->getAttribute('shoecolor')->getFrontend()->getValue($_product) ?>
Example 3
<?php $type = "simple"; $p = "0" ?> <?php foreach ($_productCollection as $_product): ?> <?php $custom = Mage::getModel('catalog/product_type_configurable')->setProduct($_product); ?> <?php $col = $custom->getUsedProductCollection()->addAttributeToSelect('shoecolor')->addFilterByRequiredOptions(); ?> <?php foreach($col as $simple_product) { $p=$simple_product->getId(); $type="configurable"; } ?> <?php if($type == "configurable"): ?> <h5><?php echo $_product->load($p)->getAttributeText('shoecolor'); ?><?php $type="simple" ?></h5> <?php endif; ?>
source share