属性集中的Magento属性

时间:2011-02-12 09:22:32

标签: magento

有人可以告诉我如何检查属性是否已创建?

我有一个显示基于给定属性的产品的块。 问题是,如果尚未创建属性,我在前端收到错误。

有没有办法检查属性是否存在?

感谢。

3 个答案:

答案 0 :(得分:3)

希望您可以获得有关以下文章中设置的属性和属性的大量信息:
http://www.blog.magepsycho.com/playing-with-attribute-set-in-magento/

由于

答案 1 :(得分:2)

$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'attribute_id');

尝试上面的代码,这意味着检查magento中指定属性的状态(如果你知道id)。

答案 2 :(得分:0)

试试这个:

$attributes = $product->getAttributes();
foreach ($attributes as $attribute) {
    if ($attribute->getIsVisibleOnFront()) {
        $value = $attribute->getFrontend()->getValue($product);
        // do something with $value here
    }
}
相关问题