本文整理汇总了PHP中Magento\Store\Model\StoreManager::reinitStores方法的典型用法代码示例。如果您正苦于以下问题:PHP StoreManager::reinitStores方法的具体用法?PHP StoreManager::reinitStores怎么用?PHP StoreManager::reinitStores使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Store\Model\StoreManager
的用法示例。
在下文中一共展示了StoreManager::reinitStores方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveStore
/**
* Update/create store (frontname: "Store View").
*
* @param int $storeId ID to update existing store or 'null' to create new one
* @param string $name
* @param string $code
* @param int $websiteId
* @param int $groupId (frontname: "Store")
* @param int $sortOrder
* @param bool $isActive
* @return \Magento\Store\Model\Store
*/
private function saveStore($storeId = null, $isActive = false, $name = null, $code = null, $websiteId = null, $groupId = null, $sortOrder = null)
{
$event = 'store_add';
/** @var \Magento\Store\Model\Store $store */
$store = $this->_manObj->create(\Magento\Store\Model\Store::class);
$store->load($storeId);
/* 'code' is required attr. and should be set for existing store */
$event = is_null($store->getCode()) ? 'store_add' : 'store_edit';
$store->setIsActive($isActive);
if (!is_null($name)) {
$store->setName($name);
}
if (!is_null($code)) {
$store->setCode($code);
}
if (!is_null($websiteId)) {
$store->setWebsiteId($websiteId);
}
if (!is_null($websiteId)) {
$store->setGroupId($groupId);
}
if (!is_null($sortOrder)) {
$store->setSortOrder($sortOrder);
}
$store->save();
/** @var \Magento\Store\Model\StoreManager */
$this->manStore->reinitStores();
/** @var \Magento\Framework\Event\ManagerInterface */
$this->manEvent->dispatch($event, ['store' => $store]);
return $store;
}
示例2: reinitStores
/**
* {@inheritdoc}
*/
public function reinitStores()
{
$this->decoratedStoreManager->reinitStores();
$this->dispatchInitCurrentStoreAfterEvent();
}