0

Would anyone know how to update the translations for 'color' attribute in Magento EAV.

I need the admin value tu remain the same (after checking if it exists), then change the values of the translations for the different Storeviews.

Many thanks!

  • Nobody really? Thanks! – Supersonic Mar 2 '15 at 12:30
3

Goto Catalog / Attributes / Manage Attributes

Search color and edit.

Open tab Manage labels and set the labels according the right shop.

To do it programmatic you should set the option

$attributeId = 92; // color

/** @var $attribute \Mage_Catalog_Model_Resource_Eav_Attribute */
$attribute = Mage::getModel('catalog/resource_eav_attribute');
$attribute->load($attributeId);

// Register attribute for the easy use of the existing block
Mage::register('entity_attribute', $attribute);

// Use options tab from edit to easy get values    
/** @var $block \Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options */
$block = Mage::app()->getLayout()
        ->getBlockSingleton('adminhtml/catalog_product_attribute_edit_tab_options');

// Get current labels, easy...
$label = $block->getLabelValues();

// Build options array
$options = array('value' => array());
foreach ($block->getOptionValues() as $optionValue) {
    $storeOption = array();
    foreach (Mage::app()->getStores(true) as $store) {
        $key = 'store' . $store->getId();
        $storeOption[$store->getId()] = $optionValue->$key;
    }
    $options['value'][$optionValue->getId()] = $storeOption;
}

// Update value #optionid for store 2
$options['value'][18][2] = 'New value';

// Show output
var_dump($label);
var_dump($options);

// Update and save data
$attribute->setFrontendLabel($label)->setOption($options)->save();
  • Sorry Jeroen, I meant programatically. – Supersonic Mar 3 '15 at 9:26
  • Maybe you could take a look in the controller for that page? – Jeroen Mar 3 '15 at 9:44
  • Bedankt Jeroen! :-) – Supersonic Mar 3 '15 at 9:48
  • edited to help you in the right direction – Jeroen Mar 3 '15 at 9:52
  • It works for the 'Manage Titles (Size, Color, etc.)' part, but not for the 'Manage Options (values of your attribute)'. Thanks! – Supersonic Mar 3 '15 at 11:09

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.