Hi All !!! As per my last post we have updated customer group prices in these I am sharing code to add/update product attributes whether its a custom or default attribute.
Have a look at the code:
Hope this will help you. Please comment in case you find any problem.
Have a look at the code:
<?php
//Upload File
if (isset($_POST['submit'])) {
if (is_uploaded_file($_FILES['filename']['tmp_name'])) {
echo "<h1>" . "File ". $_FILES['filename']['name'] ." uploaded successfully." . "</h1>";
}
//Import uploaded file to Database
$handle = fopen($_FILES['filename']['tmp_name'], "r");
$i=0;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($i>0) {
$si = Mage::getModel('catalog/product')->loadByAttribute('sku',$data[0]);
$product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($si->getId());
try{
$product->setData('custom_attr_1', $data[1]);
$product->setData('custom_attr_2', $data[2]);
$product->save();
} catch(Exception $e) {
echo $e->getMessage();
}
}
$i++;
}
fclose($handle);
}
?>
Hope this will help you. Please comment in case you find any problem.
Comments
Post a Comment