I have an attribute with the input type Dropdown
named "Example Attribute
" and two Store Views.
This attribute has a few options, but only the Admin
values are set:
How can I programmically modify the values for each Store View? For example let's say I'd like to add the name of the Store View to each value:
I have found some very complicated answers which basically propose to completely overwrite all the values, but none did exactly what I need. I have tried various snippets of code that I found but none have worked for me. I've also looked through Magento's core classes but I was unable to find anything related to my problem.
Best Answer
While all of the above answers are correct, I have also found that if you want to just update one option, you can use a shorthand version:
No need to update all the array of options, just set the one you like, like this
Here is an example adding an option to an attribute with values:
This will just modify the option "beer" for the default and second store (ok. the example is quick, just check the others for correctly getting store IDs..)