I need to add an attribute that allows multiple values - but not from a set of pre-selected values, not multiple select but multiple text fields.

One product, one or more values in the one field. These are for information/internal purposes so I cannot use something like "options" to store it.

This is to store the product rotations numbers from our warehouse, which can be several for some products. As we need to pass these on when sending the order to the warehouse, it would greatly simplify our lives to have them visible.

Product -> sku  -> rotation #1
                -> rotation #2
                -> rotation #3

I had a look at some of the native warehouse/stock modules but none of them seem to support the sku/rotation/stock model that warehouses use, if their screenshots and manuals are to be believed. If one did it, that would be my first choice.

The only multiple value attributes of that kind I could find are the media attributes but these are complicated by all the file, format etc. concerns so it is hard to see the structure on how to reproduce this. I think it'd need to have a custom attribute type created, with its own tables etc.

I have considered storing it all as xml or csv in one field but then I have to add code to pack/unpack this and it makes the whole thing a lot more work, especially when rotations disappear after being sold.

Anyone done this before? I'm looking at doing it the most standard way possible so the risk of it affecting other extensions is minimised.

I'm not really looking at tracking the stock per rotation as this would make it a much bigger project than I want to tackle. I just want the information.

1 Answer 1


Easiest way will be to create new textarea attribute and then store values comma separated:


Then when you get this value you can explode it with:

$vars = explode(',', $attr);

Your $vars will be array of elements ["var1", "var2", "var3"].

I know that this solution might not be acceptable, but if you processing data outside Magento, especially not in Frontend - that could save you a lot of time.

For the good solution: It's not that easy, but you should be able to achieve your goal if you have some experience in developing Magento Extension.

  1. You need to create new form input type, with javascript control to duplicate your original input: <input id="any_unique_id_for_input" type="text" name="your_input[]" /> Then you need to duplicate it with javascript (you will probably try to use jQuery - but it's not in Magento by default - sorry).

  2. Create attribute with type text and with your newly created input type.

  3. Before saving your product - you need to serialize, implode or json_encode values from your field to save it as one text value, like that:

    $your_input = $request->getParam('your_input'); $product->setData('your_input', implode(',', $your_input))

  4. You need to rewrite getData() method on Product Model, and check if attribute you get is type of your new input type if it is - you should return explode($value);

I've just gave you an idea, you need to search by yourself how to achieve that. Maybe a little bit better option will be to create your own product edit tab, with custom phtml for it (that will remove 1. step).

Good luck :)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.