如何在 magento 中以编程方式更新自定义选项?

2021-12-19 00:00:00 product php magento mysql magento-1.7

我有很多带有自定义选项的产品,现在我需要通过 csv 文件只更新自定义选项.那么我们如何以编程方式做到这一点?

I have lot of products with custom options, now I have requirement to update only custom options through csv file. so how we can do this programatically?

推荐答案

我找到了一种以编程方式更新自定义选项的解决方案,这是解决方案

i found one solution for updating custom options programatically here is the solution

$product = Mage::getModel('catalog/product')->load($product_id);
$values = array();
foreach ($product->getOptions() as $o) {
           $p = $o->getValues();
        }
    }
  foreach($p as $v)
        {
            $values[$v->getId()]['option_type_id']= $v->getId();
                $values[$v->getId()]['title']= 'test';
                $values[$v->getId()]['price']= 23;
                $values[$v->getId()]['price_type']= 'fixed';
                $values[$v->getId()]['sku']= $value1;

          }
        $v->setValues($values);
        $v->saveValues();
$product->save();

希望这对某人有所帮助这只会更新自定义选项值

hope this help someone this only update custom options value

相关文章