如何检查产品属性集中是否存在属性?
我需要知道一个产品是否有其属性集的属性。
使用以下代码获取属性:
$attrPricekg = Mage::getModel('catalog/product')->load($_product->getId())->getPricekg();
如果产品属性集中存在属性,则 $attrPricekg 会显示:为该产品设置值,或者如果没有设置任何值,则显示 0。
如果产品属性集中不存在属性,则 $attrPricekg 显示 0。这是我的问题...我需要避免这种情况,我想检查该产品是否不存在该属性。
谢谢。
$installer->removeAttribute('catalog_product', 'attributecode_to_look_for');
即可。 - R T