本文整理汇总了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;
}
示例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;
}
示例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;
}
}