/**
* Add new radio option 'Moby' to Application Type
* Affect products: i14, i14u, i14g
*/
$optionTitle = 'Application Type';
$values[] = array(
'title' => 'Moby',
'price' => -750,
'sku' => 'co_type_mob1',
'sort_order' => 50,
'option_type_id' => -1,
'is_delete' => 0,
'price_type' => 'fixed'
);
$fields = array(
'max_characters' => 0,
'type' => 'radio',
'title' => $optionTitle,
'values' => $values
);
Mage::helper('es/catalog_product_update')->updateOption(array('i14', 'i14g'), $optionTitle, $fields);
$values[0]['price'] = 250;
$fields['values'] = $values;
Mage::helper('es/catalog_product_update')->updateOption(array('i14u'), $optionTitle, $fields);
/**
* Set option's sku to 'co14'
* Affect products: i14, i14u, i14g
*/
$connection = $installer->getConnection();
$subSelect = $connection->select();
$subSelect->from(false, array('sku' => '"co14"'))
->join(array(
't' => $installer->getTable('catalog/product_option_title')),
't.option_id=o.option_id',
array())
->join(array(
'e' => $installer->getTable('catalog/product')),
'e.entity_id = o.product_id',
array())
->where('e.sku IN (?)', array('i14', 'i14u', 'i14g'))
->where('t.title = ?', 'Cose Name')
;
$updateQuery = $connection->updateFromSelect($subSelect, array('o' => $installer->getTable('catalog/product_option')));
$connection->query($updateQuery);
Posted by kiatng to OpenMage (2016-11-24 07:12)