2

I'm working on a product migration that involves about 200 attributes. I'm making most of these as a dropdown so that the clients can pick and choose which ones to utilize on the layered navigation (LN). They are not sure which attributes they would want exactly on the LN, so that's why I'm making them all as dropdown, instead of text field, to give them flexibility.

If I want to switch them as a text field without deleting and re-creating attributes, what do I need to do in the database? I've tested modifying values in eav_attribue's columns backend_type and frontend_input and that seems to do it without causing any problems. This is under the assumption that associated products will be removed and re-created, obviously, so that the respective attribute value are in the correct EAV tables.

Are those all I need to change in order to manually change a dropdown attribute to a text field attribute, or are there other tables involves that may potentially cause errors?

1
  • You should not ever edit the tables manually. Your best bet would be to create an installer script and use updateAttribute() to set frontend_input. Dec 20, 2013 at 23:06

1 Answer 1

2

To change the attribute type you can create a set-up script and call the following snippet:

$installer->updateAttribute('catalog_product', 'your_attribute_code', array(
    'type' => 'varchar',
    'input' => 'text',
));

But this will not copy over the currently set values on the products. I am not sure what the best way to cover this would be. Though I can give you the following information:

  1. catalog_product_entity_int: will store the id of the options selected,
  2. catalog_product_entity_varchar: is where the varchar attribute values should be stored,
  3. eav_attribute_option: this will give you the link from options to attributes,
  4. eav_attribute_option_value: this will give you the text value for each of the attribute's options,

From this you should be able to copy all the attribute values from the integer values stored in catalog_product_entity_int and make them the relevant text values stored in catalog_product_entity_varchar

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.