1

I am about to set up an online store and I am kinda "testing" if magento (1.7., Community Edition) fits my needs. I think I got the idea behind categorizing and attributing products. But I have a question to the attributes concerning products - or in detail: for configurable products.

Is it possible to "inherit" attribute values (options) from another existing attribute?

I'll give you an example to visualize my question:

Let's say we sell boxes. We would have three different types of boxes:

  1. uni-color boxes ("box-color")
  2. boxes with a seperate "top-color"
  3. boxes with a special printing on it, which has its own color ("highlight color")

To assign colors to box type #1, I would have the possible values

  • black,
  • white,
  • orange.

Box type #2 might come as

  • black box / black top (it might seem redundant, but there is a difference to uni-colored boxes),
  • black box / white top,
  • black box / orange top,
  • white box / black top,
  • white box / white top,
  • white box / orange top,
  • and so on.

And finally, box type #3 might come as

  • black box / black top / black highlight,
  • black / white / orange,
  • black / black / white,
  • etc.

I think you get the idea.

I would like to have one attribute of color-options which I would maintain (like add new colors, delete old ones, etc.) - and use it as all three different types of configurable color sets.

To be able to create configurable products I would add the color-attribute to my special "boxes" attribute set(s). But when it comes to the two-colored-boxes, I am not able to add the color attribute a second time.

Is there any other (simple) way to achieve this? Since I am new to Magento I would not like to dig too deep into the code or even want to develop a module (?).

Thanks in advance, I appreciate your answers :-)

2

Magento gives the support for what you need but it's kind of a long shot.
You are able to set a different source model to your dropdowns.
Let's take for example the attribute tax_class_id. It's a dropdown but it does not have the values stored in the database (tables eav_attribute_option and eav_attribute_option_value). The source model is tax/class_source_product that in a non-customized instance translates to class Mage_Tax_Model_Class_Source_Product.
In the case of tax_class_id the options shown in the dropdown are the result of Mage_Tax_Model_Class_Source_Product::getAllOptions().
You can create a custom extension with a custom model (or 3 - one for each attribute). Set those models to be the source model for your attributes and add your logic inside the getAllOptions() method. In this method you can get the values from a table or hard code them, even get them through an external API.
Your custom source models should extend Mage_Eav_Model_Entity_Attribute_Source_Abstract and should have the following methods:

  • getAllOptions() - this is where the logic is. This should return an array of arrays. the array at the lower level should look like array('value'=>'SOME NUMBER HERE', 'label'=>'Label here');
  • getOptionText() should be similar to the one in Mage_Tax_Model_Class_Source_Product
  • toOptionArray() similar to the one in Mage_Tax_Model_Class_Source_Product.
  • getFlatColums() similar to the one in Mage_Tax_Model_Class_Source_Product just change the column comment
  • getFlatUpdateSelect() similar to the one in Mage_Tax_Model_Class_Source_Product

Check this for a small tutorial on how to add an attribute with custom options
Also follow how the source model for tax_class_id is made. It helps.

  • Thank you. That sounds like a solution. It is a little too much hard coding for me at the moment, since I did not really dig into coding yet. I guess for testing purposes, it would be easier to continue with three different attributes with the same options. – rob_st May 24 '13 at 8:03
0

You should be able to use a single attribute for this, since the color attribtue only shows the selected value. Also the configurable products only shows the associated colors for the simple products.

  • Um ok. I couldn't figure out how. Because if I add the attribute containing the colors to the attribute set for the new (simple) product from which to create the configurable from, I can only choose one color. The way I figured was to create three different color attributes with identic options (values). – rob_st May 23 '13 at 15:26

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.