Day: December 16, 2008

  • Magento user defined attributes in product list

    Magento内置的产品属性与自定义的产品属性可访问范围不同。默认设置下,自定义的产品属性只能在product view取值,如在product view以外则取不到值;内置的产品属性则没有这种限制。

    为了让自定义产品属性能在Magento前端(比如product list, product new, 或者自己写一个product featured)随意取值,至少有三种方法可以更改默认设置。

    最简单的办法是创建一个config.xml(文件名任意),放在app/etc/modules/下:

    <?xml version="1.0"?>
    <config>
        <frontend>
            <product>
                <collection>
                    <attributes>
                        <attributeyouwant/>
                    </attributes>
                </collection>
            </product>
        </frontend>
    </config>
    

    以后有空再讲其他两种办法。记得一定要刷新Magento cache才能让设置生效!