0
我们想要使用php脚本更新我们的magento网站中的产品自定义选项数量。Magento自定义选项数量更新
如果我们使用的代码用于显示定制选项控管数量则显示细跟以下代码:
$产物=法师:: getModel( “目录/产品”) - >负载($的productId); $ attVal = $ product-> getOptions();
if($attVal){
$values = array();
foreach($attVal as $optionKey => $optionVal) {
foreach($optionVal->getValues() as $valuesKey => $valuesVal) {
echo $valuesVal->getCustomoptionsQty();
}
}
}
}
在此,当我们使用setCustomoptionQty(10)函数,那么它不与该代码的工作:
$产物=法师:: getModel( “目录/产品”) - >负载($的productId ); $ attVal = $ product-> getOptions();
if($attVal){
$values = array();
foreach($attVal as $optionKey => $optionVal) {
foreach($optionVal->getValues() as $valuesKey => $valuesVal) {
$valuesVal->setCustomoptionsQty(10);
$valuesVal->save();
}
}
}
}
try {
$product->save();
}
catch(Exception $ex) {
echo $ex->getMessage();
}
请为我提供一些解决方案,我们想要更新产品定制选项使用此功能的量化值。
什么是你的全名attibute? – 2014-09-01 09:01:05
@ChristopheFerreboeuf它不是属性,这是自定义选项的数量(customoptions_qty) – 2014-09-01 09:36:27
我不是很舒服,但你把值的值对象$ valuesVal-> setCustomoptionsQty(10)。 您应该将该值放到产品类$ product-> setCustomoptionsQty(10)(id属性名称为customoptions_qty)或某处将$ valuesVal设置为$ product。在代码中创建$ valuesVal并保存它,保存产品,但是产品不会被更改? – Martin 2014-09-29 22:56:28