Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

[solved] Product list > show custom visible attributes
 
peer1979
Jr. Member
 
Total Posts:  4
Joined:  2012-06-03
 

I’m trying to show custom (visible) attributes in the product list. I’ve googled for an answer, but did not find any working solution yet.
I’ve also tried:

1> Adding block to ‘layout/catalog.xml’ > block ‘catalog/product_list’:

<block type="catalog/product_view_attributes" name="custom_attributes" as="custom_attributes" template="catalog/product/custom_attributes.phtml" />

The template gets loaded, but it doens’t work.

2> This snippet:

$product Mage::getModel('catalog/product')->load($product_id);
$attributes $product->getAttributes();
foreach (
$attributes as $attribute)
{
    
if($attribute->getIsVisibleOnFront())
    
{
        
echo $attribute->getFrontend()->getValue($product);
    
}

This one fails on the getIsVisibleOnFront.

Who can help me?

 
Magento Community Magento Community
Magento Community
Magento Community
 
peer1979
Jr. Member
 
Total Posts:  4
Joined:  2012-06-03
 

*bump*
Really need a hint or some help on this one. Anyone?

 
Magento Community Magento Community
Magento Community
Magento Community
 
peer1979
Jr. Member
 
Total Posts:  4
Joined:  2012-06-03
 

I’ve managed to solve the problem with overriding a core class. Underneath you find the solution.

1 - read and follow : http://www.magestore.com/blog/2011/12/14/magento-certificate-class-overrides-in-magento/
2 - put new code in app/code/local/[namespace]/[module name]/block/product/view/attributes.php

public function load_product($p_i_product_id)
    
{
        
if(!Mage::registry('product') && $p_i_product_id)
        
{
            $this
->_product Mage::getModel('catalog/product')->load($p_i_product_id);
        
}
}

3 - load attributes.phtml in [your_theme_name]/default/layout/catalog.xml
4 - within attributes.phtml:

$g_obj_product_attributes = new [namespace]_[module_name]_Block_Product_View_Attributes();
$g_obj_product_attributes->load_product($g_i_product_id);

5 - You now have access to all custom attributes:

$g_obj_product_attributes->getAdditionalData()
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top