Skip to content

Commit bf5c21a

Browse files
committed
Merge pull request #13 from amarroni/changes-and-fixes
Fix Technology from select to multiselect
2 parents d86e5ea + c9b9df3 commit bf5c21a

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

app/code/local/RG/Catalog/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<config>
33
<modules>
44
<RG_Catalog>
5-
<version>0.1.2</version>
5+
<version>0.1.3</version>
66
</RG_Catalog>
77
</modules>
88
<global>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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

Comments
 (0)