Skip to content

Instantly share code, notes, and snippets.

@magefast
Last active February 5, 2024 09:18
Show Gist options
  • Save magefast/4c00f55d63190c6e569c6320e70de2da to your computer and use it in GitHub Desktop.
Save magefast/4c00f55d63190c6e569c6320e70de2da to your computer and use it in GitHub Desktop.

Revisions

  1. magefast renamed this gist Feb 5, 2024. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. magefast renamed this gist Feb 5, 2024. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. magefast created this gist Feb 5, 2024.
    34 changes: 34 additions & 0 deletions Update Store Label
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    <pre>
    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    ini_set('time_limit', 180);
    set_time_limit(180);
    require_once dirname(__FILE__) . '/app/Mage.php';
    $app = Mage::app('admin');
    umask(0);

    $mageCsv = new Varien_File_Csv();
    $mageCsv->setDelimiter(',');
    $mageCsv->setEnclosure('"');
    $data = $mageCsv->getData('/var/www/' . DS . 'attr-label-ua.csv');

    foreach ($data as $d) {
    addAttributeLabel($d[0], $d[1]);
    echo '+' . $d[0] . ' ';
    }

    function addAttributeLabel($attributeCode, $value)
    {
    $uaStoreId = 5;
    $ruStoreId = 1;
    $adminStoreId = 0;

    $value = trim($value);
    $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attributeCode);
    $labels = [];
    $labels[$adminStoreId] = $attribute->getFrontendLabel();
    $labels[$uaStoreId] = $value;
    $labels[$ruStoreId] = $attribute->getFrontendLabel();
    $attribute->setStoreLabels($labels)->save();
    }