當前位置: 首頁>>代碼示例>>PHP>>正文


PHP StoreManagerInterface::getDefaultStoreView方法代碼示例

本文整理匯總了PHP中Magento\Framework\StoreManagerInterface::getDefaultStoreView方法的典型用法代碼示例。如果您正苦於以下問題:PHP StoreManagerInterface::getDefaultStoreView方法的具體用法?PHP StoreManagerInterface::getDefaultStoreView怎麽用?PHP StoreManagerInterface::getDefaultStoreView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\StoreManagerInterface的用法示例。


在下文中一共展示了StoreManagerInterface::getDefaultStoreView方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: read

 /**
  * Read configuration by code
  *
  * @param string $code
  * @return array
  */
 public function read($code = null)
 {
     if ($this->_appState->isInstalled()) {
         if (empty($code)) {
             $store = $this->_storeManager->getStore();
         } elseif ($code == \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT) {
             $store = $this->_storeManager->getDefaultStoreView();
         } else {
             $store = $this->_storeFactory->create();
             $store->load($code);
         }
         if (!$store->getCode()) {
             throw NoSuchEntityException::singleField('storeCode', $code);
         }
         $websiteConfig = $this->_scopePool->getScope(\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, $store->getWebsite()->getCode())->getSource();
         $config = array_replace_recursive($websiteConfig, $this->_initialConfig->getData("stores|{$code}"));
         $collection = $this->_collectionFactory->create(array('scope' => \Magento\Store\Model\ScopeInterface::SCOPE_STORES, 'scopeId' => $store->getId()));
         $dbStoreConfig = array();
         foreach ($collection as $item) {
             $dbStoreConfig[$item->getPath()] = $item->getValue();
         }
         $config = $this->_converter->convert($dbStoreConfig, $config);
     } else {
         $websiteConfig = $this->_scopePool->getScope(\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT)->getSource();
         $config = $this->_converter->convert($websiteConfig, $this->_initialConfig->getData("stores|{$code}"));
     }
     return $config;
 }
開發者ID:pavelnovitsky,項目名稱:magento2,代碼行數:34,代碼來源:Store.php

示例2: setStoreId

 /**
  * Set store for resource model
  *
  * @param null|string|bool|int|Store $store
  * @return $this
  */
 public function setStoreId($store)
 {
     if (is_int($store)) {
         $this->_storeId = $store;
     } else {
         $this->_storeId = $this->_storeManager->getStore()->getId();
     }
     if (empty($this->_storeId)) {
         $this->_storeId = (int) $this->_storeManager->getDefaultStoreView()->getId();
     }
     return $this;
 }
開發者ID:pavelnovitsky,項目名稱:magento2,代碼行數:18,代碼來源:Flat.php

示例3: getCustomerModelByEmail

 /**
  * Retrieve customer model by his email.
  *
  * @param string $customerEmail
  * @param int $websiteId
  * @throws NoSuchEntityException If customer with the specified customer email not found.
  * @throws \Magento\Framework\Model\Exception If website was not specified
  * @return Customer
  */
 public function getCustomerModelByEmail($customerEmail, $websiteId = null)
 {
     $customer = $this->_customerFactory->create();
     if (!isset($websiteId)) {
         $websiteId = $this->storeManager->getDefaultStoreView()->getWebsiteId();
     }
     $customer->setWebsiteId($websiteId);
     $customer->loadByEmail($customerEmail);
     if (!$customer->getId()) {
         throw new NoSuchEntityException(NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'email', 'fieldValue' => $customerEmail]);
     } else {
         return $customer;
     }
 }
開發者ID:pavelnovitsky,項目名稱:magento2,代碼行數:23,代碼來源:Converter.php


注:本文中的Magento\Framework\StoreManagerInterface::getDefaultStoreView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。