Timeline for Upgrade script - Create new select attribute with options
Current License: CC BY-SA 3.0
25 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 25, 2017 at 10:42 | comment | added | Marius♦ | I can't seam to find the exact code in my project, but I used an adaptation of what Ben posted in his answer. | |
Jan 25, 2017 at 10:15 | comment | added | Hassan Ali Shahzad | @Marius I had seen this as well but I did not see any code how we can update after add attribute, can you please update code there? for multiselect and select ? | |
Jan 25, 2017 at 10:13 | comment | added | Marius♦ | @HassanAliShahzad you cannot do that from the declaration array only. You need extra code. I had the same question a while back. See this magento.stackexchange.com/q/29724/146 | |
Jan 25, 2017 at 10:06 | comment | added | Hassan Ali Shahzad | @Marius Can you please add code how we can update the default value as well for dropdown and for Multiselect particularly in mind. | |
Jun 9, 2016 at 12:22 | comment | added | Marius♦ |
Are you sure you added the source model to the backend and not the source field? getAllOptions sounds like a source model method.
|
|
Jun 9, 2016 at 12:11 | comment | added | Navarr | Your solution works perfectly without the specified backend - I would recommend editing it out | |
Jun 9, 2016 at 12:01 | comment | added | Navarr | I don't know if this used to work, but it certainly doesn't seem to be a proper solution anymore. "Call to undefined method Mage_Eav_Model_Entity_Attribute_Backend_Array::getAllOptions() in app/code/core/Mage/Adminhtml/Block/Widget/Form.php on line 201" is the error I get on product edit page and on PLP when enabled for layered navigation | |
Apr 20, 2016 at 10:48 | history | edited | Tim Bezhashvyly | CC BY-SA 3.0 |
deleted 21 characters in body
|
Oct 14, 2015 at 12:13 | comment | added | Marius♦ |
@mujas. backend is the equivalent of backend_model column in the eav_attribute table . An attribute can support frontend models (that are actually blocks used for rendering the attribute field in the backend), source models (for dropdown and multiselect attributes. this is the source of the options) and backend model. You can use the class you set a backend model to perform actions before the attribute value is saved or after it's loaded. You can use this to perform additional validations or to to alter the value. In this specific case, the array you send from the form is serialized.
|
|
Oct 14, 2015 at 12:00 | comment | added | Mujahidh | $Marius What is 'backend' => 'eav/entity_attribute_backend_array',.can you please explain. | |
Sep 29, 2015 at 11:25 | comment | added | Marius♦ |
@Dexter add $installer = $this; as the first line in the installer script.
|
|
Sep 29, 2015 at 10:48 | comment | added | Dexter |
@Marius I am getting an error Fatal error: Call to a member function addAttribute() on a non-object I have added <class>Mage_Catalog_Model_Resource_Setup</class> in config.xml resource script too
|
|
Mar 18, 2015 at 12:29 | comment | added | underscorePez | This technique failed for me on Magento 1.5, I upgraded to to 1.7 and it worked. Older Magento versions don't look for the array key 'values' in the Mage_Eav_Model_Entity_Setup::addAttributeOption function. | |
May 29, 2014 at 9:16 | comment | added | Mr_Green | @Marius I am going through this link which I think is different and older than yours (and also not working). do you have any link which explains step by step to create an attribute progammatically? (searching online is giving me all excerpt code answers) | |
May 29, 2014 at 8:59 | comment | added | Marius♦ |
@Mr_Green. Sure you can. You just add this 'group'=> 'Group name here' in the configuration array when creating the attribute. If the attribute group with that name exists it will be added there. If not, it will be created.
|
|
May 29, 2014 at 8:51 | comment | added | Mr_Green | @Marius Can I have the attribute in other group instead of "General" tab? I want to create a new group/tab which I am able to do using "attribute sets" in admin panel but I want to do this programmatically. So, what I am trying is creating an attribute and adding to a programmatically generated tab. | |
S Nov 7, 2013 at 19:47 | history | suggested | Judder | CC BY-SA 3.0 |
Adding options as a single 'value' means that the array is added, rather than the options in the array. Using the 'values' option means that the values are editable in the Magento Admin -> Catalog -> Attributes -> (attribute name) -> Manage Label / Options
|
Nov 7, 2013 at 19:44 | review | Suggested edits | |||
S Nov 7, 2013 at 19:47 | |||||
Jun 27, 2013 at 6:34 | comment | added | Marius♦ | @philwinkle. Yeah...4 hour week, but not every week. I don't want to get tired.:) | |
Jun 26, 2013 at 21:13 | comment | added | philwinkle | @benmarks Marius subscribes to the 4-hour work week philosophy. | |
Jun 26, 2013 at 18:55 | comment | added | Marius♦ | @benmarks. I do work for a living and I really enjoy the work I'm doing. I just like from time to time to take 2 minute breaks to answer a question. Do you want me to stop answering? :) | |
Jun 26, 2013 at 18:54 | comment | added | Marius♦ | @Marty: I don't think they are important. | |
Jun 26, 2013 at 18:38 | comment | added | benmarks | Marius, do you work for a living? :-) | |
Jun 26, 2013 at 18:30 | comment | added | Marty Wallace | are the array keys for 'value' significant? i.e. the '0', '1' and '2' ? | |
Jun 26, 2013 at 18:23 | history | answered | Marius♦ | CC BY-SA 3.0 |