如何在 magento 中以编程方式更新自定义选项? [英] How to update custom options programatically in magento?

查看:28
本文介绍了如何在 magento 中以编程方式更新自定义选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多带有自定义选项的产品,现在我需要通过 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

这篇关于如何在 magento 中以编程方式更新自定义选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆