startSetup(); $conn = $installer->getConnection(); $websites = $conn->fetchPairs("SELECT store_id, website_id FROM {$this->getTable('core_store')}"); $conn->addColumn($this->getTable('salesrule'), 'website_ids', 'text'); $select = $conn->select() ->from($this->getTable('salesrule'), array('rule_id', 'store_ids')); $rows = $conn->fetchAll($select); foreach ($rows as $r) { $websiteIds = array(); foreach (explode(',',$r['store_ids']) as $storeId) { if ($storeId!=='') { $websiteIds[$websites[$storeId]] = true; } } $conn->update($this->getTable('salesrule'), array('website_ids'=>join(',',array_keys($websiteIds))), "rule_id=".$r['rule_id'] ); } $conn->dropColumn($this->getTable('salesrule'), 'store_ids'); $installer->endSetup();