【发布时间】:2011-12-15 02:22:45
【问题描述】:
我使用安装程序脚本向我的 Magento 应用程序产品实体添加了一个自定义 eav 属性(基本上,遵循此处描述的过程:Installing Custom Attributes with Your Module)。现在,我想使用更新脚本根据某些标准(基于产品类别)更改(填充)每个产品的此属性的值。我尝试使用的脚本基本上是这样的:
$attributeValues = array(...) // Map from $productId to the desired $value
$product = Mage::getModel('catalog/product');
foreach($attributeValues as $productId=>$value){
$product->load($productId)->setMyAttribute($value);
$product->save();
}
然后我的问题是:可以在更新脚本中使用这种抽象级别(Mage::getModel('catalog/product') 及其方法)吗?如果不是,您建议如何使用更新脚本(无需 sql)更改这些属性值?
我使用的脚本(直到现在)没有工作并且失败并出现错误:
Call to a member function getStoreIds() on a non-object
在一个magento核心文件中。
我不知道这个错误是 Magento 错误还是我使用更新脚本的方式有问题。
我正在使用 Magento 1.4.0.1
【问题讨论】:
标签: sql magento installation entity-attribute-value