Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }
Ejemplo n.º 5
0
 /**
  * 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;
 }
Ejemplo n.º 6
0
 /**
  * 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;
 }
Ejemplo n.º 7
0
 /**
  * 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;
 }
Ejemplo n.º 8
0
 /**
  * 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);
     }
 }
 /**
  * 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'))));
 }