Last active
February 5, 2024 09:18
-
-
Save magefast/4c00f55d63190c6e569c6320e70de2da to your computer and use it in GitHub Desktop.
Magento1: Update Attribute Label for Store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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;