当前位置: 首页>>代码示例>>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;未经允许,请勿转载。