1

I had to switch a dropdown field to a multiselect field. Previously the values were stored as integers (in catalog_product_entity_int) but now with multiselect I have to use varchar (catalog_product_entity_varchar).

I'm not sure how to move the data from one table to another with a data script so I would be glad if someone can provide me a possible solution or any thoughts on how to do it.

I googled already a bit but I guess I use the wrong search words..

Thanks in advance

2

TO Change Single Select to Multiple Select:

UPDATE eav_attribute SET backend_model = 'eav/entity_attribute_backend_array',frontend_input = 'multiselect',backend_type = 'varchar',source_model = NULL WHERE eav_attribute.attribute_id = 136;

Copy from INT (Single Select Values) to VARCHAR:

insert into catalog_product_entity_varchar (entity_type_id, attribute_id, store_id, entity_id, value) select entity_type_id, attribute_id, store_id, entity_id, value from catalog_product_entity_int where attribute_id = 136 ;

Use your Attribute ID instead of 136

DELETE FROM catalog_product_entity_int WHERE attribute_id = 136;

After copying values from INT to VARCHAR.

0
0

As Subesh Pokhrel suggested the following solution includes his given statements. I used the data upgrade script to solve the problem with the given statements

$installer = $this;
$conn = $installer->getConnection();
$attribute_id = $installer->getAttributeId('catalog_product', 'attribute_code');

$stmt = $conn->prepare("INSERT INTO catalog_product_entity_varchar (entity_type_id, attribute_id, store_id, entity_id, value) SELECT entity_type_id, attribute_id, store_id, entity_id, value FROM catalog_product_entity_int WHERE attribute_id = :attribute_id");
$stmt->bindParam(':attribute_id', $attribute_id);
$stmt->execute();

$stmt = $conn->prepare("DELETE FROM catalog_product_entity_int WHERE attribute_id = :attribute_id");
$stmt->bindParam(':attribute_id', $attribute_id);
$stmt->execute();

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.