1+ <?php
2+ /**
3+ * Created by PhpStorm.
4+ * User: gringo
5+ * Date: 15/09/15
6+ * Time: 11:10 PM
7+ */
8+ /* @var $installer Mage_Catalog_Model_Resource_Setup */
9+ $ installer = $ this ;
10+
11+ $ installer ->startSetup ();
12+
13+ $ connection = $ installer ->getConnection ();
14+
15+ $ entityTypeId = $ installer ->getEntityTypeId (Mage_Catalog_Model_Product::ENTITY );
16+ $ attributeId = $ installer ->getAttributeId ($ entityTypeId , 'rg_gloves_technology ' );
17+ $ attributeTableOld = $ installer ->getAttributeTable ($ entityTypeId , $ attributeId );
18+
19+ //$installer->updateAttribute($entityTypeId, $attributeId, 'backend_type', 'decimal');
20+ $ installer ->updateAttribute ($ entityTypeId ,$ attributeId ,
21+ array ( 'frontend_input ' =>'multiselect ' ,
22+ 'backend_type ' =>'varchar ' ,
23+ 'backend_model ' =>'eav/entity_attribute_backend_array ' ,
24+ ));
25+
26+
27+ $ attributeTableNew = $ installer ->getAttributeTable ($ entityTypeId , $ attributeId );
28+
29+ if ($ attributeTableOld != $ attributeTableNew ) {
30+ $ connection ->disableTableKeys ($ attributeTableOld )
31+ ->disableTableKeys ($ attributeTableNew );
32+
33+ $ select = $ connection ->select ()
34+ ->from ($ attributeTableOld , array ('entity_type_id ' , 'attribute_id ' , 'store_id ' , 'entity_id ' , 'value ' ))
35+ ->where ('entity_type_id = ? ' , $ entityTypeId )
36+ ->where ('attribute_id = ? ' , $ attributeId );
37+
38+ $ query = $ select ->insertFromSelect ($ attributeTableNew ,
39+ array ('entity_type_id ' , 'attribute_id ' , 'store_id ' , 'entity_id ' , 'value ' )
40+ );
41+
42+ $ connection ->query ($ query );
43+
44+ $ connection ->delete ($ attributeTableOld ,
45+ $ connection ->quoteInto ('entity_type_id = ? ' , $ entityTypeId )
46+ . $ connection ->quoteInto (' AND attribute_id = ? ' , $ attributeId )
47+ );
48+
49+ $ connection ->enableTableKeys ($ attributeTableOld )->enableTableKeys ($ attributeTableNew );
50+ }
51+ $ installer ->endSetup ();
0 commit comments