cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 1.9 - How to write script for bulk update in table using csv?

SOLVED

Magento 1.9 - How to write script for bulk update in table using csv?

I want to add a position for products by using category id in the table catalog_category_product, how to bulk update for my 20k products and any best practice for this suggest me thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 1.9 - How to write script for bulk update in table using csv?

solved.

 

<?php
require_once 'app/Mage.php';
umask(0);
Mage::app();

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

	if (($handle = fopen("inputs.csv", "r")) !== FALSE)
	{
		while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
		{
			$sql='UPDATE catalog_product_entity_media_gallery_value SET label="'.$data[2].'" WHERE value_id = "'.$data[0].'"';
			echo $sql.'<br/>';
			mysqli_query($sql); 
		}
		fclose($handle);
	}
?>

View solution in original post

1 REPLY 1

Re: Magento 1.9 - How to write script for bulk update in table using csv?

solved.

 

<?php
require_once 'app/Mage.php';
umask(0);
Mage::app();

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

	if (($handle = fopen("inputs.csv", "r")) !== FALSE)
	{
		while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
		{
			$sql='UPDATE catalog_product_entity_media_gallery_value SET label="'.$data[2].'" WHERE value_id = "'.$data[0].'"';
			echo $sql.'<br/>';
			mysqli_query($sql); 
		}
		fclose($handle);
	}
?>