00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 $installer = $this;
00028
00029
00030 $mediaAttributeId = (int) $installer->getAttributeId('catalog_product', 'media_gallery');
00031
00032 $imagesAttributesIds = implode(",", array(
00033 (int) $installer->getAttributeId('catalog_product', 'small_image'),
00034 (int) $installer->getAttributeId('catalog_product', 'image'),
00035 (int) $installer->getAttributeId('catalog_product', 'thumbnail')
00036 ));
00037
00038
00039 $installer->startSetup();
00040 $installer->run("
00041 INSERT INTO `{$installer->getTable('catalog_product_entity_media_gallery')}` (attribute_id, entity_id, value)
00042 SELECT $mediaAttributeId as attribute_id, entity_id, `value`
00043 FROM `{$installer->getTable('catalog_product_entity_gallery')}`
00044 GROUP BY `value`;
00045
00046 INSERT INTO `{$installer->getTable('catalog_product_entity_media_gallery')}` (attribute_id, entity_id, value)
00047 SELECT $mediaAttributeId as attribute_id, entity_id, `value`
00048 FROM `{$installer->getTable('catalog_product_entity_varchar')}`
00049 WHERE attribute_id IN($imagesAttributesIds) AND store_id = 0
00050 GROUP BY `value`;
00051 ");
00052
00053 $installer->endSetup();