Magento Forum

   
Display attributes in list.phtml
 
nathansmith
Jr. Member
 
Total Posts:  14
Joined:  2009-01-26
 

I’ve got an attribute set up to create simple products from a configurable called clothing, it’s options are just sizes such as small medium large etc. The product is set up fine and the simple products are created correctly and I can select a size in a drop down on the product page. What I’d like to do is display the attribute options on the list.phtml page that are associated to each product i.e.

Product 1 Image
Product 1 Name
Product 1 Price
Small Large XXL

Product 2 Image
Product 2 Name
Product 2 Price
Med Large XL XXL

So they can see what sizes are available before clicking into the actual product page. I’ve tried a few different solutions from around the forum but none of them work, it just echos blank space.

Client is adamant the project has this feature in it so I’m abit stuck at the moment. Anyone tried/done this? Any help is appreciated.

Thanks,
Nathan

 
Magento Community Magento Community
Magento Community
Magento Community
 
jsmiller
Member
 
Total Posts:  39
Joined:  2009-09-28
 

What code are you using to pull in the values for the attribute?  I believe that list.phtml does not pull in the attribute the same way that view.phtml does.  This is the code that I am using to pull in attributes on the list page:

<?php $productattrib Mage::getModel('catalog/product')->load($_product->getId()); ?>

 
Magento Community Magento Community
Magento Community
Magento Community
 
liangrongze
Jr. Member
 
Total Posts:  11
Joined:  2009-06-08
 

I agree with jsmiller, If you want to show up the attibute ‘s label of the product, you can using this code
<h5><?php echo $this->htmlEscape($_product->getAttributeText('manufacturer'))?></h5>

 
Magento Community Magento Community
Magento Community
Magento Community
 
nathansmith
Jr. Member
 
Total Posts:  14
Joined:  2009-01-26
 
jsmiller - 12 November 2009 12:35 PM

What code are you using to pull in the values for the attribute?  I believe that list.phtml does not pull in the attribute the same way that view.phtml does.  This is the code that I am using to pull in attributes on the list page:

<?php $productattrib Mage::getModel('catalog/product')->load($_product->getId()); ?>

Will this work for an attribute with multiple values? For example I need to be able to call the attribute ‘clothing’ and have it echo the associated values i.e. small, medium etc (but only if they’re saleable i.e. qty > 1) Tried both of these solutions and got nothing :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
jsmiller
Member
 
Total Posts:  39
Joined:  2009-09-28
 

Try this:

$attributes Mage::getModel('catalogsearch/advanced')->getAttributes();
$attributeArray=array();
foreach(
$attributes as $a){
if($a->getAttributeCode() == 'desired_attribute_code'){
foreach($a->getSource()->getAllOptions(false) as $option){
$attributeArray[$option[
'value']] $option['label'];
}
}
}

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top