当前位置: 首页>>代码示例>>PHP>>正文


PHP StoreManagerInterface::setCurrentStore方法代码示例

本文整理汇总了PHP中Magento\Framework\StoreManagerInterface::setCurrentStore方法的典型用法代码示例。如果您正苦于以下问题:PHP StoreManagerInterface::setCurrentStore方法的具体用法?PHP StoreManagerInterface::setCurrentStore怎么用?PHP StoreManagerInterface::setCurrentStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\StoreManagerInterface的用法示例。


在下文中一共展示了StoreManagerInterface::setCurrentStore方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCatalogPrice

 /**
  * Minimal price for "regular" user
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param null|\Magento\Store\Model\Store $store Store view
  * @param bool $inclTax
  * @return null|float
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function getCatalogPrice(\Magento\Catalog\Model\Product $product, $store = null, $inclTax = false)
 {
     // Workaround to avoid loading stock status by admin's website
     if ($store instanceof \Magento\Store\Model\Store) {
         $oldStore = $this->storeManager->getStore();
         $this->storeManager->setCurrentStore($store);
     }
     $subProducts = $product->getTypeInstance()->getAssociatedProducts($product);
     if ($store instanceof \Magento\Store\Model\Store) {
         $this->storeManager->setCurrentStore($oldStore);
     }
     if (!count($subProducts)) {
         return null;
     }
     $minPrice = null;
     foreach ($subProducts as $subProduct) {
         $subProduct->setWebsiteId($product->getWebsiteId())->setCustomerGroupId($product->getCustomerGroupId());
         if ($subProduct->isSalable()) {
             if ($this->commonPriceModel->getCatalogPrice($subProduct) < $minPrice || $minPrice === null) {
                 $minPrice = $this->commonPriceModel->getCatalogPrice($subProduct);
                 $product->setTaxClassId($subProduct->getTaxClassId());
             }
         }
     }
     return $minPrice;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:35,代码来源:CatalogPrice.php

示例2: getCatalogPrice

 /**
  * Minimal price for "regular" user
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param null|\Magento\Store\Model\Store $store Store view
  * @param bool $inclTax
  * @return null|float
  */
 public function getCatalogPrice(\Magento\Catalog\Model\Product $product, $store = null, $inclTax = false)
 {
     if ($store instanceof \Magento\Store\Model\Store) {
         $oldStore = $this->storeManager->getStore();
         $this->storeManager->setCurrentStore($store);
     }
     $this->coreRegistry->unregister('rule_data');
     $this->coreRegistry->register('rule_data', new \Magento\Framework\Object(array('store_id' => $product->getStoreId(), 'website_id' => $product->getWebsiteId(), 'customer_group_id' => $product->getCustomerGroupId())));
     $minPrice = $product->getPriceModel()->getTotalPrices($product, 'min', $inclTax);
     if ($store instanceof \Magento\Store\Model\Store) {
         $this->storeManager->setCurrentStore($oldStore);
     }
     return $minPrice;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:22,代码来源:CatalogPrice.php

示例3: process

 /**
  * Process path info
  *
  * @param string $pathInfo
  * @return string
  * @throws NoSuchEntityException
  */
 public function process($pathInfo)
 {
     $pathParts = $this->stripPathBeforeStorecode($pathInfo);
     $storeCode = $pathParts[0];
     $stores = $this->storeManager->getStores(false, true);
     if (isset($stores[$storeCode])) {
         $this->storeManager->setCurrentStore($storeCode);
         $path = '/' . (isset($pathParts[1]) ? $pathParts[1] : '');
     } else {
         $this->storeManager->setCurrentStore(\Magento\Store\Model\Store::DEFAULT_CODE);
         $path = '/' . implode('/', $pathParts);
     }
     return $path;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:21,代码来源:PathProcessor.php

示例4: process

 /**
  * Process path info
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @param string $pathInfo
  * @return string
  */
 public function process(\Magento\Framework\App\RequestInterface $request, $pathInfo)
 {
     $pathParts = explode('/', ltrim($pathInfo, '/'), 2);
     $storeCode = $pathParts[0];
     $stores = $this->_storeManager->getStores(false, true);
     if (isset($stores[$storeCode]) && $stores[$storeCode]->isUseStoreInUrl()) {
         if (!$request->isDirectAccessFrontendName($storeCode)) {
             $this->_storeManager->setCurrentStore($storeCode);
             $pathInfo = '/' . (isset($pathParts[1]) ? $pathParts[1] : '');
             return $pathInfo;
         } elseif (!empty($storeCode)) {
             $request->setActionName('noroute');
             return $pathInfo;
         }
         return $pathInfo;
     }
     return $pathInfo;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:25,代码来源:PathInfoProcessor.php

示例5: stopEnvironmentEmulation

 /**
  * Stop environment emulation
  *
  * Function restores initial store environment
  *
  * @param \Magento\Framework\Object $initialEnvironmentInfo information about environment of the initial store
  * @return \Magento\Core\Model\App\Emulation
  */
 public function stopEnvironmentEmulation(\Magento\Framework\Object $initialEnvironmentInfo)
 {
     $this->_restoreInitialInlineTranslation($initialEnvironmentInfo->getInitialTranslateInline());
     $initialDesign = $initialEnvironmentInfo->getInitialDesign();
     $this->_restoreInitialDesign($initialDesign);
     // Current store needs to be changed right before locale change and after design change
     $this->_storeManager->setCurrentStore($initialDesign['store']);
     $this->_restoreInitialLocale($initialEnvironmentInfo->getInitialLocaleCode(), $initialDesign['area']);
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:18,代码来源:Emulation.php

示例6: getPdf

 /**
  * Return PDF document
  *
  * @param  array $invoices
  * @return \Zend_Pdf
  */
 public function getPdf($invoices = array())
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('invoice');
     $pdf = new \Zend_Pdf();
     $this->_setPdf($pdf);
     $style = new \Zend_Pdf_Style();
     $this->_setFontBold($style, 10);
     foreach ($invoices as $invoice) {
         if ($invoice->getStoreId()) {
             $this->_localeResolver->emulate($invoice->getStoreId());
             $this->_storeManager->setCurrentStore($invoice->getStoreId());
         }
         $page = $this->newPage();
         $order = $invoice->getOrder();
         /* Add image */
         $this->insertLogo($page, $invoice->getStore());
         /* Add address */
         $this->insertAddress($page, $invoice->getStore());
         /* Add head */
         $this->insertOrder($page, $order, $this->_scopeConfig->isSetFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $order->getStoreId()));
         /* Add document text and number */
         $this->insertDocumentNumber($page, __('Invoice # ') . $invoice->getIncrementId());
         /* Add table */
         $this->_drawHeader($page);
         /* Add body */
         foreach ($invoice->getAllItems() as $item) {
             if ($item->getOrderItem()->getParentItem()) {
                 continue;
             }
             /* Draw item */
             $this->_drawItem($item, $page, $order);
             $page = end($pdf->pages);
         }
         /* Add totals */
         $this->insertTotals($page, $invoice);
         if ($invoice->getStoreId()) {
             $this->_localeResolver->revert();
         }
     }
     $this->_afterGetPdf();
     return $pdf;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:49,代码来源:Invoice.php

示例7: getPdf

 /**
  * Format pdf file
  *
  * @param  null $shipment
  * @return \Zend_Pdf
  */
 public function getPdf($shipment = null)
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('shipment');
     $pdf = new \Zend_Pdf();
     $this->_setPdf($pdf);
     $page = $this->newPage();
     if ($shipment->getStoreId()) {
         $this->_localeResolver->emulate($shipment->getStoreId());
         $this->_storeManager->setCurrentStore($shipment->getStoreId());
     }
     $this->_setFontRegular($page);
     $this->_drawHeaderBlock($page);
     $this->y = 740;
     $this->_drawPackageBlock($page);
     $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
     $this->_afterGetPdf();
     if ($shipment->getStoreId()) {
         $this->_localeResolver->revert();
     }
     return $pdf;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:28,代码来源:Packaging.php

示例8: _reinitStores

 /**
  * Initialize currently ran store
  *
  * @param \Magento\Framework\StoreManagerInterface $storage
  * @param array $arguments
  * @return void
  * @throws \Magento\Framework\App\InitException
  */
 protected function _reinitStores(\Magento\Framework\StoreManagerInterface $storage, $arguments)
 {
     Profiler::start('init_stores');
     $storage->reinitStores();
     Profiler::stop('init_stores');
     $scopeCode = $arguments['scopeCode'];
     $scopeType = $arguments['scopeType'] ?: ScopeInterface::SCOPE_STORE;
     if (empty($scopeCode) && false == is_null($storage->getWebsite(true))) {
         $scopeCode = $storage->getWebsite(true)->getCode();
         $scopeType = ScopeInterface::SCOPE_WEBSITE;
     }
     switch ($scopeType) {
         case ScopeInterface::SCOPE_STORE:
             $storage->setCurrentStore($scopeCode);
             break;
         case ScopeInterface::SCOPE_GROUP:
             $storage->setCurrentStore($this->_getStoreByGroup($storage, $scopeCode));
             break;
         case ScopeInterface::SCOPE_WEBSITE:
             $storage->setCurrentStore($this->_getStoreByWebsite($storage, $scopeCode));
             break;
         default:
             throw new \Magento\Framework\App\InitException('Store Manager has not been initialized properly');
     }
     $currentStore = $storage->getStore()->getCode();
     if (!empty($currentStore)) {
         $this->_checkCookieStore($storage, $scopeType);
         $this->_checkRequestStore($storage, $scopeType);
     }
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:38,代码来源:StorageFactory.php

示例9: execute

 /**
  * Search for attributes by part of attribute's label in admin store
  *
  * @return void
  */
 public function execute()
 {
     $this->storeManager->setCurrentStore(\Magento\Store\Model\Store::ADMIN_CODE);
     $this->getResponse()->representJson($this->coreHelper->jsonEncode($this->attributeList->getSuggestedAttributes($this->getRequest()->getParam('label_part'))));
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:10,代码来源:SuggestConfigurableAttributes.php


注:本文中的Magento\Framework\StoreManagerInterface::setCurrentStore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。