Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 /**
  * 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;
 }
Esempio n. 3
0
 /**
  * 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;
     }
 }