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.


<?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); } ?> 

How to alter my script for Magento 1.9?

submitted by /u/aveeva7
[link] [comments]