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 $installer->startSetup();
00030 $installer->run("
00031 DROP TABLE IF EXISTS {$this->getTable('catalog_product_website')};
00032 CREATE TABLE {$this->getTable('catalog_product_website')} (
00033 `product_id` INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
00034 `website_id` SMALLINT(5) UNSIGNED NOT NULL,
00035 PRIMARY KEY (`product_id`, `website_id`),
00036 CONSTRAINT `FK_CATALOG_PRODUCT_WEBSITE_WEBSITE` FOREIGN KEY `FK_CATALOG_PRODUCT_WEBSITE_WEBSITE` (`website_id`)
00037 REFERENCES `{$this->getTable('core_website')}` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00038 CONSTRAINT `FK_CATALOG_WEBSITE_PRODUCT_PRODUCT` FOREIGN KEY `FK_CATALOG_WEBSITE_PRODUCT_PRODUCT` (`product_id`)
00039 REFERENCES `{$this->getTable('catalog/product')}` (`entity_id`) ON DELETE CASCADE
00040 );
00041
00042 DROP TABLE IF EXISTS {$this->getTable('catalog_product_status')};
00043 DROP TABLE IF EXISTS {$this->getTable('catalog_product_visibility')};
00044 DROP TABLE IF EXISTS {$this->getTable('catalog_product_type')};
00045 ");
00046 $installer->endSetup();
00047 $productTable = $this->getTable('catalog_product_entity');
00048 $installer->getConnection()->dropColumn($productTable, 'parent_id');
00049 $installer->getConnection()->dropColumn($productTable, 'store_id');
00050 $installer->getConnection()->dropColumn($productTable, 'is_active');
00051
00052 try {
00053 $installer->run("
00054 INSERT INTO {$this->getTable('catalog_product_website')}
00055 SELECT DISTINCT ps.product_id, cs.website_id
00056 FROM {$this->getTable('catalog_product_store')} ps, {$this->getTable('core_store')} cs
00057 WHERE cs.store_id=ps.store_id AND ps.store_id>0;
00058 DROP TABLE IF EXISTS {$this->getTable('catalog_product_store')};
00059 ");
00060 } catch (Exception $e) {
00061 }
00062
00063 $categoryTable = $this->getTable('catalog/category');
00064 $installer->getConnection()->dropForeignKey($categoryTable, 'FK_CATALOG_CATEGORY_ENTITY_TREE_NODE');
00065
00066 try {
00067 $this->run("ALTER TABLE `{$this->getTable('catalog/category')}` ADD `path` VARCHAR( 255 ) NOT NULL, ADD `position` INT NOT NULL;");
00068 } catch (Exception $e) {
00069 }
00070 try {
00071 $this->run("DROP TABLE IF EXISTS `{$this->getTable('catalog/category_tree')}`;");
00072 } catch (Exception $e) {
00073 }
00074
00075 $installer->getConnection()->dropKey($categoryTable, 'FK_catalog_category_ENTITY_ENTITY_TYPE');
00076 $installer->getConnection()->dropKey($categoryTable, 'FK_catalog_category_ENTITY_STORE');
00077 $installer->getConnection()->dropColumn($categoryTable, 'store_id');
00078
00079 $tierPriceTable = $this->getTable('catalog_product_entity_tier_price');
00080 $installer->getConnection()->dropColumn($tierPriceTable, 'entity_type_id');
00081 $installer->getConnection()->dropColumn($tierPriceTable, 'attribute_id');
00082 $installer->getConnection()->dropForeignKey($tierPriceTable, 'FK_CATALOG_PRODUCT_ENTITY_TIER_PRICE_ATTRIBUTE');
00083 $installer->getConnection()->dropKey($tierPriceTable, 'FK_CATALOG_PRODUCT_ENTITY_TIER_PRICE_ATTRIBUTE');
00084
00085 $installer->startSetup();
00086 $installer->installEntities();
00087 $installer->endSetup();
00088
00089 $this->convertOldTreeToNew();