本文整理汇总了PHP中Magento\Store\Model\Website::getDefaultStore方法的典型用法代码示例。如果您正苦于以下问题:PHP Website::getDefaultStore方法的具体用法?PHP Website::getDefaultStore怎么用?PHP Website::getDefaultStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Store\Model\Website
的用法示例。
在下文中一共展示了Website::getDefaultStore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send customer email
*
* @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function send()
{
if ($this->_website === null || $this->_customer === null) {
return false;
}
if ($this->_type == 'price' && count($this->_priceProducts) == 0 || $this->_type == 'stock' && count($this->_stockProducts) == 0) {
return false;
}
if (!$this->_website->getDefaultGroup() || !$this->_website->getDefaultGroup()->getDefaultStore()) {
return false;
}
if ($this->_customer->getStoreId() > 0) {
$store = $this->_storeManager->getStore($this->_customer->getStoreId());
} else {
$store = $this->_website->getDefaultStore();
}
$storeId = $store->getId();
if ($this->_type == 'price' && !$this->_scopeConfig->getValue(self::XML_PATH_EMAIL_PRICE_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId)) {
return false;
} elseif ($this->_type == 'stock' && !$this->_scopeConfig->getValue(self::XML_PATH_EMAIL_STOCK_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId)) {
return false;
}
if ($this->_type != 'price' && $this->_type != 'stock') {
return false;
}
$this->_appEmulation->startEnvironmentEmulation($storeId);
if ($this->_type == 'price') {
$this->_getPriceBlock()->setStore($store)->reset();
foreach ($this->_priceProducts as $product) {
$product->setCustomerGroupId($this->_customer->getGroupId());
$this->_getPriceBlock()->addProduct($product);
}
$block = $this->_getPriceBlock();
$templateId = $this->_scopeConfig->getValue(self::XML_PATH_EMAIL_PRICE_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
} else {
$this->_getStockBlock()->setStore($store)->reset();
foreach ($this->_stockProducts as $product) {
$product->setCustomerGroupId($this->_customer->getGroupId());
$this->_getStockBlock()->addProduct($product);
}
$block = $this->_getStockBlock();
$templateId = $this->_scopeConfig->getValue(self::XML_PATH_EMAIL_STOCK_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
$alertGrid = $this->_appState->emulateAreaCode(\Magento\Framework\App\Area::AREA_FRONTEND, [$block, 'toHtml']);
$this->_appEmulation->stopEnvironmentEmulation();
$transport = $this->_transportBuilder->setTemplateIdentifier($templateId)->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId])->setTemplateVars(['customerName' => $this->_customerHelper->getCustomerName($this->_customer), 'alertGrid' => $alertGrid])->setFrom($this->_scopeConfig->getValue(self::XML_PATH_EMAIL_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId))->addTo($this->_customer->getEmail(), $this->_customerHelper->getCustomerName($this->_customer))->getTransport();
$transport->sendMessage();
return true;
}
示例2: getDefaultStore
/**
* {@inheritdoc}
*/
public function getDefaultStore()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getDefaultStore');
if (!$pluginInfo) {
return parent::getDefaultStore();
} else {
return $this->___callPlugins('getDefaultStore', func_get_args(), $pluginInfo);
}
}
示例3: testGetDefaultStore
public function testGetDefaultStore()
{
$defaultStore = $this->_model->getDefaultStore();
$this->assertInstanceOf('Magento\\Store\\Model\\Store', $defaultStore);
$this->assertEquals(1, $defaultStore->getId());
}