Reputation: 127
I have 32000 products in Magento,
When I added them I have set custom option attribute to products they work perfectly, but now I want to change the price of custom option attribute of all products.
Is there any way to change price by query or any other tricks ??
Upvotes: 1
Views: 1257
Reputation: 4073
Try the below code with your file in root folder
<?php
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();
$product = Mage::getModel('catalog/product')->load($product_id);
$values = array();
foreach ($product->getOptions() as $o) {
$p = $o->getValues();
foreach($p as $v) {
$id = $v->getId();
$values[$id]['option_type_id']= $v->getId();
$values[$id]['title']= 'test';
$values[$id]['price']= 'your_price';
$values[$id]['price_type']= 'fixed';
$values[$id]['sku']= $value1;
}
$v->setValues($values);
$v->saveValues();
}
$product->save();
?>
Upvotes: 2