Get store ids
$storeIds=array();
$storeIds=array(0,1,2,3);
get all option it value and label of admin store
$attributeFrontend = Mage::getModel('eav/config')->getAttribute('catalog_product', 'color');
if ($attributeFrontend->usesSource()) {
$items = $attributeFrontend->getSource()->getAllOptions(false,true);
}
load attribute by attribute id
$attribute = Mage::getModel('catalog/resource_eav_attribute');
$attribute->load(92);
Init some temp arrays in which assign value and it all parameters
$value=array();
$order=array();
$delete=array();
$options = array();
Create new array and save value
if ($attribute->usesSource()) {
foreach ($items as $eachOption) {
/* set Option value for store */
$optionValuetionId=$eachOption['value'];
foreach($storeIds as $sr):
if($sr==0):
$value[$optionValuetionId][$sr]=$eachOption['label'];
else:
$value[$optionValuetionId][$sr]="BERA";
endif;
endforeach;
/* end of Option value for store */
$order[$optionValuetionId]=11;
/*$delete[$optionValuetionId] set for null for not delete */
$delete[$optionValuetionId]='';
}
/* NEW VaLUES */
$data=array('value'=>$value,'delete'=>$delete,'order'=>$order);
$SetData=array('option'=>$data);
$attribute->addData($SetData);
$attribute->save();
}
Array format is like below and has been taken from Mage_Adminhtml_Catalog_Product_AttributeController
saveAction print_r($data['option']).
2015-03-28T18:31:29+00:00 DEBUG (7): Array
(
[value] => Array
(
[20] => Array
(
[0] => Black
[1] => Black
[2] =>
[3] =>
)
[27] => Array
(
[0] => Blue
[1] => Blue
[2] =>
[3] =>
)
[221] => Array
(
[0] => Brown
[1] => Brown
[2] =>
[3] =>
)
[17] => Array
(
[0] => Charcoal
[1] => Charcoal
[2] =>
[3] =>
)
[24] => Array
(
[0] => Green
[1] => Green
[2] =>
[3] =>
)
[12] => Array
(
[0] => Grey
[1] => Grey
[2] =>
[3] =>
)
[26] => Array
(
[0] => Indigo
[1] => Indigo
[2] =>
[3] =>
)
[13] => Array
(
[0] => Ivory
[1] => Ivory
[2] =>
[3] =>
)
[25] => Array
(
[0] => Khaki
[1] => Khaki
[2] =>
[3] =>
)
[226] => Array
(
[0] => Oatmeal
[1] => Oatmeal
[2] =>
[3] =>
)
[19] => Array
(
[0] => Orange
[1] => Cognac
[2] =>
[3] =>
)
[21] => Array
(
[0] => Pink
[1] => Pink
[2] =>
[3] =>
)
[18] => Array
(
[0] => Purple
[1] => Purple
[2] => aaaa
[3] =>
)
[28] => Array
(
[0] => Red
[1] => Red
[2] =>
[3] =>
)
[16] => Array
(
[0] => Royal Blue
[1] => Royal Blue
[2] => hhhhhhh
[3] =>
)
[15] => Array
(
[0] => Silver
[1] => Silver
[2] =>
[3] =>
)
[14] => Array
(
[0] => Taupe
[1] => Taupe
[2] =>
[3] =>
)
[22] => Array
(
[0] => White
[1] => White
[2] =>
[3] =>
)
[23] => Array
(
[0] => Yellow
[1] => Yellow
[2] => amit
[3] =>
)
)
[order] => Array
(
[20] => 0
[27] => 0
[221] => 0
[17] => 0
[24] => 0
[12] => 0
[26] => 0
[13] => 0
[25] => 0
[226] => 0
[19] => 0
[21] => 0
[18] => 0
[28] => 0
[16] => 0
[15] => 0
[14] => 0
[22] => 0
[23] => 0
)
[delete] => Array
(
[20] =>
[27] =>
[221] =>
[17] =>
[24] =>
[12] =>
[26] =>
[13] =>
[25] =>
[226] =>
[19] =>
[21] =>
[18] =>
[28] =>
[16] =>
[15] =>
[14] =>
[22] =>
[23] =>
)
)