1

Try to bulk update label name in catalog_product_entity_media_gallery_value,

CSV formate :

enter image description here

Workout:

<?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?

1

Try this code

<?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);
$connection=Mage::getSingleton('core/resource')->getConnection('core_write');
    if (($handle = fopen("inputs.csv", "r")) !== FALSE)
    {
        while (($data = fgetcsv($handle, '1000', ",")) !== FALSE)
        {


            $sql = "UPDATE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_media_gallery_value') . " cped
                SET  cped.label = ?
            WHERE  cped.value_id = ?";
            $connection->query($sql, array($data['2'], $data['0']));


        }
        fclose($handle);
    }
?>
  • Thank You, In Magento 2.3 instead of this -> Mage::getSingleton('core/resource')->getTableName(' ') what i should be replace? – zus Mar 11 at 10:36
  • are you developer? – Jinesh Mar 11 at 10:37
  • Please accept my answer for this post stackoverflow.com/questions/56829263/… – Jinesh Mar 11 at 10:38
  • Yes, learning Magento 2.3 – zus Mar 11 at 10:38
  • 1
    Try following way to get table name in magento2 :- $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of object manager $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); $connection = $resource->getConnection(); $tableName = $resource->getTableName('employee'); – Jinesh Mar 11 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.