예제 #1
0
 /**
  * get store id for static block and join them into array
  *
  * @param integer $blockId
  * @return array
  */
 protected function _joinBlockStoreIds($blockId)
 {
     /** @var \Mage_Core_Model_Resource $resource */
     $resource = \Mage::getSingleton('core/resource');
     $list = [];
     $readConnection = $resource->getConnection('core_read');
     $query = $readConnection->select()->from('cms_block_store')->where("block_id='{$blockId}'");
     $results = $readConnection->fetchAll($query);
     foreach ($results as $store) {
         $code = \Mage::getModel('core/store')->load($store['store_id'])->getCode();
         $extendedId = $this->_parser->createExtendedId('store', 'code', 'id', $code);
         $list[] = $extendedId;
     }
     return $list;
 }
예제 #2
0
 /**
  * save all stores
  *
  * @return array
  */
 protected function _saveStores()
 {
     $config = [];
     foreach (\Mage::app()->getWebsites() as $website) {
         foreach ($website->getGroups() as $group) {
             foreach ($group->getStores() as $store) {
                 try {
                     $this->_showActionMessage(['save store: ' . $store->getName()], $this->_configurationCounter);
                     $code = \Mage::getModel('core/website')->load($group['website_id'])->getCode();
                     $config[] = ['store/createstore', 'parameters' => ['name' => $store->getName(), 'code' => $store->getCode(), 'group' => $this->_parser->createExtendedId('group', 'id', 'default_group_id', $code), 'website' => $this->_parser->createExtendedId('website', 'code', 'id', $code)]];
                     echo $this->_colorizeString("[OK]\n", 'green');
                 } catch (\Exception $error) {
                     echo $this->_colorizeString("[ERROR]\n", 'red');
                     $this->_prepareErrorMessage($error, $this->_configurationCounter);
                 }
                 $this->_configurationCounter++;
             }
         }
     }
     return $config;
 }