/** * 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; }
/** * 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; }
/** * 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; }
/** * Create staging websites * * @param Enterprise_Staging_Model_Staging $staging * @param Enterprise_Staging_Model_Staging_Event $event * * @return Enterprise_Staging_Model_Staging_Adapter_Website */ public function createRun(Enterprise_Staging_Model_Staging $staging, $event = null) { parent::createRun($staging, $event); $websites = $staging->getMapperInstance()->getWebsites(); foreach ($websites as $website) { $masterWebsiteId = $website->getMasterWebsiteId(); $masterWebsite = Mage::app()->getWebsite($masterWebsiteId); $stagingWebsite = Mage::getModel('core/website'); $stagingWebsite->setData('is_staging', 1); $stagingWebsite->setData('code', $website->getCode()); $stagingWebsite->setData('name', $website->getName()); $stagingWebsite->setData('base_url', $website->getBaseUrl()); $stagingWebsite->setData('base_secure_url', $website->getBaseSecureUrl()); $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)); } if (!$stagingWebsite->getId()) { $value = Mage::getModel('core/date')->gmtDate(); $stagingWebsite->setCreatedAt($value); } else { $value = Mage::getModel('core/date')->gmtDate(); $stagingWebsite->setUpdatedAt($value); } $stagingWebsite->save(); if (Mage::getStoreConfigFlag('general/content_staging/create_entry_point')) { $entryPoint = Mage::getModel('enterprise_staging/entry')->setWebsite($stagingWebsite)->save(); } else { $entryPoint = null; } $stagingWebsiteId = (int) $stagingWebsite->getId(); $website->setStagingWebsite($stagingWebsite); $website->setStagingWebsiteId($stagingWebsiteId); $website->setMasterWebsite($masterWebsite); $this->_saveSystemConfig($staging, $stagingWebsite, $entryPoint); $staging->setMasterWebsiteId($masterWebsiteId)->setStagingWebsiteId($stagingWebsiteId)->setDontRunStagingProccess(true)->save(); Mage::dispatchEvent('staging_website_create_after', array('old_website_id' => $masterWebsiteId, 'new_website_id' => $stagingWebsiteId)); // curently supports only one staging website break; } return $this; }