Skip to main content

Posts

Showing posts from January, 2016

Add/Update product attribute using CSV in Magento

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: <?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());              

Add/Update Customer group product price using CSV in Magento

Hi Guys!!! After a long time I am back on posting. While working on a project I came with a problem of updating customer group pricing in magento using CSV. Well not  a big problem, let first discuss the logic. There are two tables in magento updates when you add customer group price: 1) catalog_product_index_group_price 2) catalog_product_entity_group_price So here is 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>";         //readfile($_FILES['filename']['tmp_name']);     }     //Import uploaded file to Database     $handle = fopen($_FILES['filename']['tmp_name'], "r");     $i=0;     while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {