如何在magento中创建简单的产品属性选项值

时间:2011-08-30 20:41:04

标签: php magento attributes product

我在magento中创建了自己的属性集,假设“MyAttribSet”包含大量选项值。
如何检索这些值并以编程方式为每个值分配/创建一个简单的产品? I found code sample here, but I'm missing the latter part with option values:

我使用的Magento版本是1.5.0.1

1 个答案:

答案 0 :(得分:1)

我解决了这个问题:

require_once 'app/Mage.php';
Mage::app('');
$attribute = Mage::getModel('eav/config')
             ->getAttribute('catalog_product', '955');
    foreach ( $attribute->getSource()->getAllOptions(true) as $option){

  //here comes the code sample (see link before)
                  .
                  .
                  .
  $product->setMyCustomAttribute($option['value']);
}