00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * @category Mage 00016 * @package Mage_CatalogIndex 00017 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00018 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00019 */ 00020 00021 class Mage_CatalogIndex_Model_Mysql4_Setup extends Mage_Core_Model_Resource_Setup 00022 { 00023 protected $_storeToWebsite = null; 00024 00025 public function convertStoreToWebsite($table) 00026 { 00027 $assignment = $this->_getStoreToWebsiteAssignments(); 00028 foreach ($assignment as $website=>$stores) { 00029 $this->_setWebsiteInfo($table, $website, $stores); 00030 } 00031 return $this; 00032 } 00033 00034 protected function _getStoreToWebsiteAssignments() 00035 { 00036 if (is_null($this->_storeToWebsite)) { 00037 $this->_storeToWebsite = array(); 00038 $websiteCollection = Mage::getModel('core/website')->getCollection(); 00039 foreach ($websiteCollection as $website) { 00040 $this->_storeToWebsite[$website->getId()] = $website->getStoreIds(); 00041 } 00042 } 00043 00044 return $this->_storeToWebsite; 00045 } 00046 00047 protected function _setWebsiteInfo($table, $websiteId, $storeIds) 00048 { 00049 $this->getConnection()->update( 00050 $table, 00051 array('website_id'=>$websiteId), 00052 $this->getConnection()->quoteInto('store_id IN (?)', $storeIds) 00053 ); 00054 00055 return $this; 00056 } 00057 }