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.
Magento1: Update Attribute Label for Store
<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();
}
@magefast
Copy link
Author

magefast commented Feb 5, 2024

file attr-label-ua.csv - included prepared data
1 column - attribute code
2 column - label value for store

Store IDs:
$uaStoreId = 5;
$ruStoreId = 1;
$adminStoreId = 0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment