dpluv
dpluv

Reputation: 127

how to change custom option price by query in magento?

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.

please see image

Is there any way to change price by query or any other tricks ??

Upvotes: 1

Views: 1257

Answers (1)

Slimshadddyyy
Slimshadddyyy

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

Related Questions