开发者

Cannot access new product attributes in grid display

I added a couple new attribute to my products(a boolean "yes/no" fields). They are variables to enable/disable the price from displaying on the product detail page, and grid view.

I managed to get it work on the product info page. But on product grid page I cant seem to access those variable. Specifically, the template i am working with is catalog/product/list.phtml.

Ive tried adding them in the xml file like this layout/catalog.xml:

<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
    <action method="addAttribute"><name>DisplayPrice</name></action>
    <action method="addAttribute"><name>CustomOrder</name></action>               

</block>

and I am trying to access the attributes like so in catalog/product/list.phtml:

<?php echo $_product->getDisplayPriceName()? "Yes" : "No" ; echo $_product->getCustomOrderName()? "Yes" : "No" ;?>

ive also added in the Mage config file app/code/core/Catalog/etc/config.xml:

<frontend>
<!---- stuff before this -->
        <product>
            <collection>
                <attributes>
                    <name />
                    <url_key />
       开发者_运维百科             <price />
                    <special_price />
                    <custom_order />      <!--new attribute -->
                    <display_price />     <!--new attribute -->
                    <special_from_date />
                    <special_to_date />
                    <short_description />
                    <thumbnail />
                    <small_image />
                    <image_label />
                    <thumbnail_label />
                    <small_image_label />
                    <tax_class_id />
                    <status />
                    <news_from_date />
                    <news_to_date />
                    <created_at />
                    <updated_at />
                </attributes>
            </collection>
        </product>
    </frontend>

At this point im shooting in the dark. I dont know enough about the Magento backend to know where else i need to go or look. ANY feed back will be greatly appreciated.

thanks in advance.


When loading your products specify what custom attributes you wanted loaded.Magento is not loading them by default.. although in my opinion it should.

$products = Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToSelect("custom_order")
    ->addAttributeToSelect("display_price ") 
;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜