/**
  * Check whether element should be displayed
  *
  * @return bool
  */
 public function isVisible()
 {
     $showInScope = array(\Magento\Store\Model\ScopeInterface::SCOPE_STORE => $this->_hasVisibilityValue('showInStore'), \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE => $this->_hasVisibilityValue('showInWebsite'), \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT => $this->_hasVisibilityValue('showInDefault'));
     if ($this->_storeManager->isSingleStoreMode()) {
         $result = !$this->_hasVisibilityValue('hide_in_single_store_mode') && array_sum($showInScope);
         return $result;
     }
     return !empty($showInScope[$this->_scope]);
 }
示例#2
0
 /**
  * Add stores data to collection
  *
  * @return $this
  */
 public function addStoreData()
 {
     if (!$this->_storeManager->isSingleStoreMode()) {
         if (!$this->_isCollectionLoaded) {
             $this->_addStoreDataFlag = true;
         } elseif (!$this->_addStoreDataFlag) {
             $this->_addStoreData();
         }
     }
     return $this;
 }
示例#3
0
 /**
  * Retrieve label of attribute scope
  *
  * GLOBAL | WEBSITE | STORE
  *
  * @param Attribute $attribute
  * @return string
  */
 public function getScopeLabel($attribute)
 {
     $html = '';
     if ($this->_storeManager->isSingleStoreMode()) {
         return $html;
     }
     if ($attribute->isScopeGlobal()) {
         $html .= '<br/>' . __('[GLOBAL]');
     } elseif ($attribute->isScopeWebsite()) {
         $html .= '<br/>' . __('[WEBSITE]');
     } elseif ($attribute->isScopeStore()) {
         $html .= '<br/>' . __('[STORE VIEW]');
     }
     return $html;
 }
示例#4
0
 /**
  * Set correct scope if isSingleStoreMode = true
  *
  * @param \Magento\Backend\Model\Config\Structure\Element\Field $fieldConfig
  * @param \Magento\Framework\App\Config\ValueInterface $dataObject
  * @return void
  */
 protected function _checkSingleStoreMode(\Magento\Backend\Model\Config\Structure\Element\Field $fieldConfig, $dataObject)
 {
     $isSingleStoreMode = $this->_storeManager->isSingleStoreMode();
     if (!$isSingleStoreMode) {
         return;
     }
     if (!$fieldConfig->showInDefault()) {
         $websites = $this->_storeManager->getWebsites();
         $singleStoreWebsite = array_shift($websites);
         $dataObject->setScope('websites');
         $dataObject->setWebsiteCode($singleStoreWebsite->getCode());
         $dataObject->setScopeCode($singleStoreWebsite->getCode());
         $dataObject->setScopeId($singleStoreWebsite->getId());
     }
 }
示例#5
0
 /**
  * Assign theme to the stores
  *
  * @param \Magento\Framework\View\Design\ThemeInterface $theme
  * @param array $stores
  * @param string $scope
  * @return $this
  */
 public function assignToStore($theme, array $stores = array(), $scope = \Magento\Store\Model\ScopeInterface::SCOPE_STORES)
 {
     $isReassigned = false;
     $this->_unassignThemeFromStores($theme->getId(), $stores, $scope, $isReassigned);
     if ($this->_storeManager->isSingleStoreMode()) {
         $this->_assignThemeToDefaultScope($theme->getId(), $isReassigned);
     } else {
         $this->_assignThemeToStores($theme->getId(), $stores, $scope, $isReassigned);
     }
     if ($isReassigned) {
         $this->_configCache->clean();
         $this->_layoutCache->clean();
     }
     $this->_eventManager->dispatch('assign_theme_to_stores_after', array('stores' => $stores, 'scope' => $scope, 'theme' => $theme));
     return $this;
 }
示例#6
0
 /**
  * Add rating info to select
  *
  * @param int $storeId
  * @return $this
  */
 public function addRatingInfo($storeId = null)
 {
     $adapter = $this->getConnection();
     $ratingCodeCond = $adapter->getIfNullSql('title.value', 'rating.rating_code');
     $this->getSelect()->join(array('rating' => $this->getTable('rating')), 'rating.rating_id = main_table.rating_id', array('rating_code'))->joinLeft(array('title' => $this->getTable('rating_title')), $adapter->quoteInto('main_table.rating_id=title.rating_id AND title.store_id = ?', (int) $this->_storeManager->getStore()->getId()), array('rating_code' => $ratingCodeCond));
     if (!$this->_storeManager->isSingleStoreMode()) {
         if ($storeId == null) {
             $storeId = $this->_storeManager->getStore()->getId();
         }
         if (is_array($storeId)) {
             $condition = $adapter->prepareSqlCondition('store.store_id', array('in' => $storeId));
         } else {
             $condition = $adapter->quoteInto('store.store_id = ?', $storeId);
         }
         $this->getSelect()->join(array('store' => $this->getTable('rating_store')), 'main_table.rating_id = store.rating_id AND ' . $condition);
     }
     $adapter->fetchAll($this->getSelect());
     return $this;
 }
示例#7
0
 /**
  * Get default theme which declared in configuration
  *
  * Write default theme to core_config_data
  *
  * @param string|null $area
  * @param array $params
  * @return string|int
  */
 public function getConfigurationDesignTheme($area = null, array $params = array())
 {
     if (!$area) {
         $area = $this->getArea();
     }
     $theme = null;
     $store = isset($params['store']) ? $params['store'] : null;
     if ($this->_isThemePerStoveView($area)) {
         if ($this->_storeManager->isSingleStoreMode()) {
             $theme = $this->_scopeConfig->getValue(self::XML_PATH_THEME_ID, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT);
         } else {
             $theme = (string) $this->_scopeConfig->getValue(self::XML_PATH_THEME_ID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store);
         }
     }
     if (!$theme && isset($this->_themes[$area])) {
         $theme = $this->_themes[$area];
     }
     return $theme;
 }
示例#8
0
 /**
  * Review summary
  *
  * @param \Magento\Review\Model\Rating $object
  * @param boolean $onlyForCurrentStore
  * @return array
  */
 public function getReviewSummary($object, $onlyForCurrentStore = true)
 {
     $adapter = $this->_getReadAdapter();
     $sumColumn = new \Zend_Db_Expr("SUM(rating_vote.{$adapter->quoteIdentifier('percent')})");
     $countColumn = new \Zend_Db_Expr('COUNT(*)');
     $select = $adapter->select()->from(array('rating_vote' => $this->getTable('rating_option_vote')), array('sum' => $sumColumn, 'count' => $countColumn))->joinLeft(array('review_store' => $this->getTable('review_store')), 'rating_vote.review_id = review_store.review_id', array('review_store.store_id'));
     if (!$this->_storeManager->isSingleStoreMode()) {
         $select->join(array('rating_store' => $this->getTable('rating_store')), 'rating_store.rating_id = rating_vote.rating_id AND rating_store.store_id = review_store.store_id', array());
     }
     $select->where('rating_vote.review_id = :review_id')->group('rating_vote.review_id')->group('review_store.store_id');
     $data = $adapter->fetchAll($select, array(':review_id' => $object->getReviewId()));
     if ($onlyForCurrentStore) {
         foreach ($data as $row) {
             if ($row['store_id'] == $this->_storeManager->getStore()->getId()) {
                 $object->addData($row);
             }
         }
         return $object;
     }
     $result = array();
     $stores = $this->_storeManager->getStore()->getResourceCollection()->load();
     foreach ($data as $row) {
         $clone = clone $object;
         $clone->addData($row);
         $result[$clone->getStoreId()] = $clone;
     }
     $usedStoresId = array_keys($result);
     foreach ($stores as $store) {
         if (!in_array($store->getId(), $usedStoresId)) {
             $clone = clone $object;
             $clone->setCount(0);
             $clone->setSum(0);
             $clone->setStoreId($store->getId());
             $result[$store->getId()] = $clone;
         }
     }
     return array_values($result);
 }
示例#9
0
 /**
  * Check if Single Store Mode is enabled
  *
  * @return bool
  */
 public function isSingleStoreMode()
 {
     return $this->_storeManager->isSingleStoreMode();
 }