예제 #1
0
 /**
  * Assign theme to the stores
  *
  * @param int $themeId
  * @param array $stores
  * @param string $scope
  * @param string $area
  * @return Mage_Core_Model_Theme
  * @throws UnexpectedValueException
  */
 public function assignThemeToStores($themeId, array $stores = array(), $scope = Mage_Core_Model_Config::SCOPE_STORES, $area = Mage_Core_Model_App_Area::AREA_FRONTEND)
 {
     /** @var $theme Mage_Core_Model_Theme */
     $theme = $this->_themeFactory->create()->load($themeId);
     if (!$theme->getId()) {
         throw new UnexpectedValueException('Theme is not recognized. Requested id: ' . $themeId);
     }
     $themeCustomization = $theme->isVirtual() ? $theme : $this->createThemeCustomization($theme);
     $configPath = $this->_design->getConfigPathByArea($area);
     // Unassign given theme from stores that were unchecked
     /** @var $config Mage_Core_Model_Config_Data */
     foreach ($this->_getAssignedScopesCollection($scope, $configPath) as $config) {
         if ($config->getValue() == $themeId && !in_array($config->getScopeId(), $stores)) {
             $this->_app->getConfig()->deleteConfig($configPath, $scope, $config->getScopeId());
         }
     }
     if (count($stores) > 0) {
         foreach ($stores as $storeId) {
             $this->_app->getConfig()->saveConfig($configPath, $themeCustomization->getId(), $scope, $storeId);
         }
         $this->_app->cleanCache(Mage_Core_Model_Config::CACHE_TAG);
     }
     $this->_makeTemporaryLayoutUpdatesPermanent($themeId, $stores);
     $this->_app->cleanCache(array('layout', Mage_Core_Model_Layout_Merge::LAYOUT_GENERAL_CACHE_TAG));
     $this->_eventManager->dispatch('assign_theme_to_stores_after', array('themeService' => $this, 'themeId' => $themeId, 'stores' => $stores, 'scope' => $scope, 'area' => $area, 'theme' => $theme, 'themeCustomization' => $themeCustomization));
     return $themeCustomization;
 }
예제 #2
0
 /**
  * Set current VDE theme
  */
 protected function _setTheme()
 {
     $themeId = $this->_backendSession->getData('theme_id');
     if ($themeId !== null) {
         $path = $this->_designPackage->getConfigPathByArea(Mage_Core_Model_App_Area::AREA_FRONTEND);
         $this->_application->getStore()->setConfig($path, $themeId);
     }
 }