1

How to retrieve only certains attribute's options for a given attribute set, in admin, in new product and edit form ?

For Example, two attribute set (e.g., set-1 and set-2).

In each, color attribute is assigned and color has options (e.g., blue, yellow, green, red).

The goal of the question is to be able to set 'blue' and 'yellow' as available options of color in set-1,

and to set 'green' and 'red' as available options of color in set-2,

instead of having all options.

Any suggestion is welcome.

  • From the admin? – Robbie Averill Jun 15 '16 at 6:18
  • yes, easier from the admin, but not necessary – vhanahrni Jun 15 '16 at 6:23
  • Just disable the products with the options you don't want in each set – Robbie Averill Jun 15 '16 at 6:24
1

There is no way to do this out of the box (honestly, I have no idea why would you want to do that, but anyway...).

This is just an idea, I don't have much code for it.
You can control the options from a dropdown attribute if you use a custom source model.
Here is a tutorial on how to create a product attribute with a custom source model.
I would suggest creating a simple CRUD module where you manage your colors. Each color you add should have a multiselect field that contains all the attribute sets and you can select for each color in which attribute set to go.
Then, in the source model, in the getAllOptions method, just check the current attribute set for the product and display only the colors assigned to that attribute set.
The downside is that when you create a new attribute set that contains your attribute you will have to go through all the items in your CRUD module and assign them to that attribute set.
But you can overcome this by adding a mass action to the grid of your module that allows you to mass assign or unassign colors to/from an attribute set.

  • Following your idea, does the db table eav_entity_attribute will need new column 'attribute_option_id' ? – vhanahrni Jun 15 '16 at 11:25
  • Nope. You should not change any existing tables. – Marius Jun 15 '16 at 11:39

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.