0

we converted dropdown attribute to muti-select attribute using following queries:

step1)

UPDATE eav_attribute SET
entity_type_id = '10',
attribute_model = NULL,
backend_model = 'eav/entity_attribute_backend_array',
backend_type = 'varchar',
backend_table = NULL,
frontend_model = NULL,
frontend_input = 'multiselect',
frontend_class = NULL
WHERE attribute_id = '1244';

step 2)

INSERT INTO catalog_product_entity_varchar ( entity_type_id, attribute_id, store_id, entity_id, value)
SELECT 10, 1244, 1, entity_id, value 
FROM catalog_product_entity_int
WHERE attribute_id = 1244;

step 3)

DELETE FROM catalog_product_entity_int
WHERE entity_type_id = 10 and attribute_id = 1244;

Now what values we gave before for dropdown attribute is displaying in frontnend. but it did't selected those values in backend after we changed to multiselect attribute we done reindex many times.

credits : http://swarminglabs.com/how-to-change-a-product-dropdown-attribute-to-a-multi-select/

2

Attribute after moving from SELECT to MULTISELECT is working. It's getting saved in the backend.

As suggested by "David Verholen", it's not good to use DIRECT SQL Queries. Always must use Install/Upgrade Script.

Additionally, I would recommend you check the below:

In your STORE VIEW, the values for this attribute "multiselect" must be selected and the checkbox "Use Default" can/cannot (optional) be checked.

Check this and let me know if you are able to display this in your frontend.

Additionally, to be able to display the multi select attribute you might need to use $_product->getAttributeText('custom_attribute'). This will display an array of ids say 721, 722, 723 and then you might need to run a foreach to display the correct values like below (dirty hack but works):

I did this in /catalog/product/view/attributes.phtml file

<?php
$_ageValues = $_product->getAttributeText($_data['code']);
$count = 1;
if(is_array($_ageValues)):
    foreach($_ageValues as $_ageValue):
        if($count > 1) { echo ","; }
        echo $_ageValue;
        $count++;
    endforeach; 
else: echo $_product->getAttributeText($_data['code']);
endif;
?>

Happy Coding...

  • you are a star in magento..... – Baby in Magento Feb 10 '16 at 10:55
  • Additionally, to be able to display the multi select attribute you might need to use $_product->getAttributeText('custom_attribute'). This will display an array of ids say 721, 722, 723 and then you might need to run a foreach to display the correct values. – Shivani Feb 10 '16 at 10:57
  • sure, i will try that. – Baby in Magento Feb 10 '16 at 10:59
  • nice! I already thought today I was wrong in one point, it actually should work to copy the values from int table to varchar. It just does not work if you do it the other way from multiselect to select – David Verholen Feb 10 '16 at 16:41
  • @DavidVerholen perfect words, agreed for that. – Baby in Magento Feb 10 '16 at 18:51
1

the tutorial is actually wrong.

For a select field, in the catalog_product_entity_int table, each attribute option id is stored in a single row. The actual values are stored in another table.

For a multiselect Field (this is managed by the Backend Model) the values are stored comma separated in a single row in catalog_product_entity_varchar.

So you can't just copy the values from one table to the other. You have to convert them

===UPDATE===

i was wrong about this. The tutorial actually should work but given some special store configs there was more to do mentioned here:

attribute values are displaying in frontend only from store view

  • now what values i gave for dropdown is displaying in frontend. but those values are did't selected in backend. and if i change any values in backend , its not reflecting in frontend. – Baby in Magento Feb 10 '16 at 6:20
  • please give me sql queries for solving this issue – Baby in Magento Feb 10 '16 at 6:24
  • to be honest you should not be Using sql queries if your not exactly knowing what you are doing. I would have also have to make some tests to get this working since it is not a simple one. If I find time later I'll update the answer, but currently I don't have a testing env for this – David Verholen Feb 10 '16 at 6:34
  • you are absolutely right. i followed comments of that post, since i got positive comments, so i did this. please check when you are free. – Baby in Magento Feb 10 '16 at 6:35
  • yea just read the comments. He seems pretty convinced that this works :P I'm wondering if hes right for magento 1.7 – David Verholen Feb 10 '16 at 6:43

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.