Created
February 17, 2017 20:51
-
-
Save VIVEKLUCKY249/f02c531737d5dce8d811a3011fd14aa3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$magePath = 'app/Mage.php'; | |
require_once $magePath; | |
Varien_Profiler::enable(); | |
Mage::setIsDeveloperMode(true); | |
ini_set('display_errors', 1); | |
error_reporting(E_ALL); | |
umask(0); | |
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); | |
$product_ids = array(1004); | |
$productmodel = Mage::getModel('catalog/product'); | |
foreach ($product_ids as $product_id) { | |
$cos = array(); | |
$co = array(); | |
$product = $productmodel->load($product_id); | |
$options = $product->getProductOptionsCollection(); | |
if (isset($options)) { | |
foreach ($options as $o) { | |
$title = $o->getTitle(); | |
$optionType = $o->getType(); | |
//test type | |
if ($optionType == "drop_down" && $title == "Go ahead ?") { | |
//getting collection of value related to current option | |
$values = $o->getValuesCollection(); | |
$found = false; | |
foreach ($values as $k => $v) { | |
//test existing of value for update | |
if (1 == preg_match("/Ja$/i", $v->getTitle())) { | |
//update and save | |
$v->setTitle("Ja")->setSku("Vivek")->setPriceType("fixed")->setSortOrder(2)->setPrice(floatval(300.0000)); | |
$v->setStoreId(0); | |
$v->setOption($o)->save(); | |
$cos[] = $v->toArray($co); | |
} | |
} | |
} | |
$o->setData("values", $cos)->save(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment