本文介紹了如何在 magento 中以編程方式更新自定義選項(xiàng)?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我有很多帶有自定義選項(xiàng)的產(chǎn)品,現(xiàn)在我需要通過(guò) csv 文件只更新自定義選項(xiàng).那么我們?nèi)绾我跃幊谭绞阶龅竭@一點(diǎn)?
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?
推薦答案
我找到了一種以編程方式更新自定義選項(xiàng)的解決方案,這是解決方案
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();
希望這對(duì)某人有所幫助這只會(huì)更新自定義選項(xiàng)值
hope this help someone this only update custom options value
這篇關(guān)于如何在 magento 中以編程方式更新自定義選項(xiàng)?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!