1

I try to update labels options on my size label in an installer. I use the following code :

$attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product', 'size_label');
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);

$attribute->setData('option', array(
    'value'=> array($optionId => array (
        0 => 'default label',
        1 => 'FR label',
        2 => 'DE label',
        3 => 'ES label',
        [...]
        )),
    'order' => array($optionId => $orderId)
    )
);

$attribute->save();

This code work when I use it like a script, but if I use it in my installer, there is an issue on this line :

$attribute->save();

In both case, $attribute->getData() return the same array..

When I launch the installer, that remove all my label (even the default one "default label"), but I still have the line on my BO with the position.

Someone now what could be the difference between the script and the installer ? Why that work in the first one and not in the second one ? Any idea ?

8
  • What is $orderId and $optionId here? Commented Sep 12, 2018 at 15:42
  • Just simple numbers (examples : "520" or "286").
    – Kozame
    Commented Sep 12, 2018 at 15:48
  • So basically you want to add options for your size attribute through installer. Right? Commented Sep 12, 2018 at 15:50
  • I want update label option for my size attribute (for each store). Sorry if it's not clear :S
    – Kozame
    Commented Sep 12, 2018 at 15:52
  • Understand. So your code is showing only for one option to update. Right? Commented Sep 12, 2018 at 15:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.