How to add multi Select value save in Magento from CSV file.

It is Little bit complex. First of all review my code and then customize your own way.

$csvFile = ‘./var/import/attribute.csv’; // This is csv file of attribute. you can save var/import/attribute.csv folder.

$file_handle = fopen($csvFile, ‘r’);
$skArray=  array();
$i= 0;
while (($data = fgetcsv($file_handle, 1024, ‘,’)) !== FALSE) {
if ($i == 0) { // removing header value of csv file.
$i++; continue;
}
$bendtoTip = $data[0]; // this is first column array.
// finding
if (!empty($bendtoTip)) {
$bendtoTip = trim($bendtoTip);
$temp = explode(‘,’, $bendtoTip);

$countAttributeValue = count($temp);

if ($countAttributeValue > 1) {

for ($j = 0; $j < $countAttributeValue; $j++) {
if (!in_array(trim($temp[$j]), $attributeOption)) {
$attributeOption[] = trim($temp[$j]);
}
}
} else {
if (!in_array($bendtoTip, $attributeOption)) {
$attributeOption[] = $bendtoTip;
}
}
}
//$result = $data[0];

$i++;
}
fclose($handle);
//echo “<pre>”;
//print_r($attributeOption);
//exit;
$arg_value = array();
$arg_attribute = ‘bladematerial’;
$arg_value = $attributeOption;
$temp = count($arg_value);

$attr_model = Mage::getModel(‘catalog/resource_eav_attribute’);
$attr = $attr_model->loadByCode(‘catalog_product’, $arg_attribute);
$attr_id = $attr->getAttributeId();

$option[‘attribute_id’] = $attr_id;
for($p = 0; $p!= $temp; $p++){
$option[‘value’][‘option’.$p][0] = $arg_value[$p];
}

$setup = new Mage_Eav_Model_Entity_Setup(‘core_setup’);
$setup->addAttributeOption($option);