Reputation: 194
We want to update product custom option quantity in our magento website using php script.
If we used code for showing custom option quanity then it is showing fine with following code :
$product = Mage::getModel("catalog/product")->load($productId); $attVal = $product->getOptions();
if($attVal){
$values = array();
foreach($attVal as $optionKey => $optionVal) {
foreach($optionVal->getValues() as $valuesKey => $valuesVal) {
echo $valuesVal->getCustomoptionsQty();
}
}
}
}
Under this when we used setCustomoptionQty(10) function then it is not working with this code :
$product = Mage::getModel("catalog/product")->load($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();
}
Please provide me some solution for this, we want to update product custom options quanity value for using this function.
Upvotes: 0
Views: 878
Reputation: 327
It should be:
$product = Mage::getModel( 'catalog/product' )->load( $productId );
$product->setCustomoptionsQty(10)->save();
Upvotes: 0