本文介紹了如何在 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 中以編程方式更新自定義選項?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!