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 $installer->startSetup();
00031
00032 $conn = $installer->getConnection();
00033 $websites = $conn->fetchPairs("SELECT store_id, website_id FROM {$this->getTable('core_store')}");
00034
00035 $conn->addColumn($this->getTable('salesrule'), 'website_ids', 'text');
00036
00037 $select = $conn->select()
00038 ->from($this->getTable('salesrule'), array('rule_id', 'store_ids'));
00039 $rows = $conn->fetchAll($select);
00040
00041 foreach ($rows as $r) {
00042 $websiteIds = array();
00043 foreach (explode(',',$r['store_ids']) as $storeId) {
00044 if ($storeId!=='') {
00045 $websiteIds[$websites[$storeId]] = true;
00046 }
00047 }
00048 $conn->update($this->getTable('salesrule'),
00049 array('website_ids'=>join(',',array_keys($websiteIds))),
00050 "rule_id=".$r['rule_id']
00051 );
00052 }
00053 $conn->dropColumn($this->getTable('salesrule'), 'store_ids');
00054
00055 $installer->endSetup();