コード例 #1
0
ファイル: Group.php プロジェクト: jpbender/mage_virtual
 /**
  * Enter description here...
  *
  * @param Enterprise_Staging_Model_Staging $staging
  * @param Enterprise_Staging_Model_Staging_Event $event
  *
  * @return Enterprise_Staging_Model_Staging_Adapter_Group
  */
 public function createRun(Enterprise_Staging_Model_Staging $staging, $event = null)
 {
     parent::createRun($staging, $event);
     $websites = $staging->getMapperInstance()->getWebsites();
     $createdStoreGroups = array();
     foreach ($websites as $website) {
         $stores = $website->getStores();
         foreach ($stores as $store) {
             $realStore = Mage::app()->getStore($store->getMasterStoreId());
             if (!$realStore) {
                 continue;
             }
             if (array_key_exists($realStore->getGroupId(), $createdStoreGroups)) {
                 $store->setGroupId($createdStoreGroups[$realStore->getGroupId()]);
                 continue;
             }
             $realStoreGroup = $realStore->getGroup();
             $rootCategory = (int) $realStoreGroup->getRootCategoryId();
             $stagingGroup = Mage::getModel('core/store_group');
             $stagingGroup->setData('website_id', $website->getStagingWebsiteId());
             $stagingGroup->setData('root_category_id', $rootCategory);
             $stagingGroup->setData('name', $realStoreGroup->getName());
             $stagingGroup->save();
             $masterWebsite = $website->getMasterWebsite();
             $stagingWebsite = $website->getStagingWebsite();
             if ($stagingWebsite && $realStoreGroup->getId() == $masterWebsite->getDefaultGroupId()) {
                 $stagingWebsite->setData('default_group_id', $stagingGroup->getId());
                 $stagingWebsite->save();
             }
             $store->setGroupId($stagingGroup->getId());
             $createdStoreGroups[$realStore->getGroupId()] = $stagingGroup->getId();
         }
     }
     return $this;
 }
コード例 #2
0
ファイル: Item.php プロジェクト: jpbender/mage_virtual
 /**
  * Enter description here...
  *
  * @param Enterprise_Staging_Model_Staging $staging
  * @param Enterprise_Staging_Model_Staging_Event $event
  *
  * @return Enterprise_Staging_Model_Staging_Adapter_Item
  */
 public function createRun(Enterprise_Staging_Model_Staging $staging, $event = null)
 {
     parent::createRun($staging, $event);
     $stagingItems = $staging->getMapperInstance()->getStagingItems();
     foreach ($stagingItems as $stagingItem) {
         $item = Mage::getModel('enterprise_staging/staging_item')->loadFromXmlStagingItem($stagingItem);
         $staging->addItem($item);
     }
     $staging->saveItems();
     return $this;
 }
コード例 #3
0
ファイル: Store.php プロジェクト: jpbender/mage_virtual
 /**
  * Create staging store views
  *
  * @param Enterprise_Staging_Model_Staging $staging
  * @param Enterprise_Staging_Model_Staging_Event $event
  *
  * @return Enterprise_Staging_Model_Staging_Adapter_Store
  */
 public function createRun(Enterprise_Staging_Model_Staging $staging, $event = null)
 {
     parent::createRun($staging, $event);
     $websites = $staging->getMapperInstance()->getWebsites();
     $masterWebsite = $staging->getMasterWebsite();
     $defaultStoreId = null;
     if ($masterWebsite) {
         $masterDefaultGroup = $masterWebsite->getDefaultGroup();
         if ($masterDefaultGroup) {
             $defaultStoreId = $masterDefaultGroup->getDefaultStoreId();
         }
     }
     foreach ($websites as $website) {
         $stores = $website->getStores();
         foreach ($stores as $masterStoreId => $store) {
             $stagingStore = Mage::getModel('core/store');
             $stagingStore->setData('is_active', 1);
             $stagingStore->setData('is_staging', 1);
             $stagingStore->setData('code', $store->getCode());
             $stagingStore->setData('name', $store->getName());
             $stagingWebsite = $website->getStagingWebsite();
             if ($stagingWebsite) {
                 $stagingStore->setData('website_id', $website->getStagingWebsiteId());
                 $stagingStore->setData('group_id', $stagingWebsite->getDefaultGroupId());
             }
             if ($store->getGroupId()) {
                 $stagingStore->setData('group_id', $store->getGroupId());
             }
             if (!$stagingStore->getId()) {
                 $value = Mage::getModel('core/date')->gmtDate();
                 $stagingStore->setCreatedAt($value);
             } else {
                 $value = Mage::getModel('core/date')->gmtDate();
                 $stagingStore->setUpdatedAt($value);
             }
             $stagingStore->save();
             if ($stagingWebsite) {
                 $defaultGroup = $stagingWebsite->getDefaultGroup();
                 if ($defaultGroup) {
                     if (!$defaultGroup->getDefaultStoreId() && (is_null($defaultStoreId) || $stagingStore->getId() == $defaultStoreId)) {
                         $defaultGroup->setDefaultStoreId($stagingStore->getId());
                         $defaultGroup->save();
                     }
                 }
             }
             $store->setStagingStore($stagingStore);
             $store->setStagingStoreId($stagingStore->getId());
         }
     }
     return $this;
 }
コード例 #4
0
ファイル: Website.php プロジェクト: jpbender/mage_virtual
 /**
  * Update staging websites staging values (visibility, master_login and master_password)
  *
  * @param Enterprise_Staging_Model_Staging $staging
  * @param Enterprise_Staging_Model_Staging_Event $event
  *
  * @return Enterprise_Staging_Model_Staging_Adapter_Website
  */
 public function updateRun(Enterprise_Staging_Model_Staging $staging, $event = null)
 {
     parent::updateRun($staging, $event);
     $websites = $staging->getMapperInstance()->getWebsites();
     foreach ($websites as $website) {
         $masterWebsiteId = $website->getMasterWebsiteId();
         $stagingWebsiteId = $website->getStagingWebsiteId();
         if ($stagingWebsiteId) {
             $stagingWebsite = Mage::app()->getWebsite($stagingWebsiteId);
         }
         if (!$stagingWebsite->getId() || !$stagingWebsite->getIsStaging()) {
             continue;
         }
         $stagingWebsite->setData('visibility', $website->getVisibility());
         $stagingWebsite->setData('master_login', $website->getMasterLogin());
         $password = trim($website->getMasterPassword());
         if ($password) {
             if (Mage::helper('core/string')->strlen($password) < 6) {
                 throw new Enterprise_Staging_Exception(Mage::helper('enterprise_staging')->__('The password must have at least 6 characters. Leading or trailing spaces will be ignored.'));
             }
             $stagingWebsite->setData('master_password', Mage::helper('core')->encrypt($password));
         }
         $stagingWebsite->save();
         break;
     }
     return $this;
 }
コード例 #5
0
ファイル: Default.php プロジェクト: jpbender/mage_virtual
 /**
  * Return Staging table name with all prefixes
  *
  * @param string $entityName
  * @param string $internalPrefix
  * @return string
  */
 public function getStagingTableName($entityName, $internalPrefix = '')
 {
     $table = $this->getTable($entityName);
     if (isset($this->_processedTables[$table])) {
         return $this->_processedTables[$table];
     }
     return parent::getStagingTableName($table, $internalPrefix);
 }