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


PHP StoreManagerInterface::getStore方法代码示例

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


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

示例1: aroundDispatch

 /**
  * @param \Magento\Framework\App\Action\Action $subject
  * @param callable $proceed
  * @param \Magento\Framework\App\RequestInterface $request
  *
  * @return \Magento\Framework\App\ResponseInterface
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @throws \Magento\Framework\App\InitException
  */
 public function aroundDispatch(\Magento\Framework\App\Action\Action $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
 {
     if (!$this->_storeManager->getStore()->getIsActive()) {
         throw new \Magento\Framework\App\InitException('Current store is not active.');
     }
     return $proceed($request);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:16,代码来源:StoreCheck.php

示例2: execute

 /**
  * Display search result
  *
  * @return void
  */
 public function execute()
 {
     /* @var $query \Magento\CatalogSearch\Model\Query */
     $query = $this->_objectManager->get('Magento\\CatalogSearch\\Helper\\Data')->getQuery();
     $query->setStoreId($this->_storeManager->getStore()->getId());
     if ($query->getQueryText() != '') {
         if ($this->_objectManager->get('Magento\\CatalogSearch\\Helper\\Data')->isMinQueryLength()) {
             $query->setId(0)->setIsActive(1)->setIsProcessed(1);
         } else {
             if ($query->getId()) {
                 $query->setPopularity($query->getPopularity() + 1);
             } else {
                 $query->setPopularity(1);
             }
             if ($query->getRedirect()) {
                 $query->save();
                 $this->getResponse()->setRedirect($query->getRedirect());
                 return;
             } else {
                 $query->prepare();
             }
         }
         $this->_objectManager->get('Magento\\CatalogSearch\\Helper\\Data')->checkNotes();
         $this->_view->loadLayout();
         $this->_view->getLayout()->initMessages();
         $this->_view->renderLayout();
         if (!$this->_objectManager->get('Magento\\CatalogSearch\\Helper\\Data')->isMinQueryLength()) {
             $query->save();
         }
     } else {
         $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl());
     }
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:38,代码来源:Index.php

示例3: set

 /**
  * {@inheritdoc}
  */
 public function set(\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod $method, $cartId)
 {
     $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId());
     $payment = $this->paymentMethodBuilder->build($method, $quote);
     if ($quote->isVirtual()) {
         // check if billing address is set
         if (is_null($quote->getBillingAddress()->getCountryId())) {
             throw new InvalidTransitionException('Billing address is not set');
         }
         $quote->getBillingAddress()->setPaymentMethod($payment->getMethod());
     } else {
         // check if shipping address is set
         if (is_null($quote->getShippingAddress()->getCountryId())) {
             throw new InvalidTransitionException('Shipping address is not set');
         }
         $quote->getShippingAddress()->setPaymentMethod($payment->getMethod());
     }
     if (!$quote->isVirtual() && $quote->getShippingAddress()) {
         $quote->getShippingAddress()->setCollectShippingRates(true);
     }
     if (!$this->zeroTotalValidator->isApplicable($payment->getMethodInstance(), $quote)) {
         throw new InvalidTransitionException('The requested Payment Method is not available.');
     }
     $quote->setTotalsCollectedFlag(false)->collectTotals()->save();
     return $quote->getPayment()->getId();
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:29,代码来源:WriteService.php

示例4: _beforeSave

 /**
  * Prepare data before save
  *
  * @param \Magento\Framework\Object $object
  * @return $this
  */
 protected function _beforeSave($object)
 {
     if (!$object->getData($this->getAttribute()->getAttributeCode())) {
         $object->setData($this->getAttribute()->getAttributeCode(), $this->_storeManager->getStore()->getId());
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:13,代码来源:Store.php

示例5: _getConfigUrl

 /**
  * Get url for config settings where base url option can be changed
  *
  * @return string
  */
 protected function _getConfigUrl()
 {
     $output = '';
     $defaultUnsecure = $this->_config->getValue(\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, 'default');
     $defaultSecure = $this->_config->getValue(\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, 'default');
     if ($defaultSecure == \Magento\Store\Model\Store::BASE_URL_PLACEHOLDER || $defaultUnsecure == \Magento\Store\Model\Store::BASE_URL_PLACEHOLDER) {
         $output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', array('section' => 'web'));
     } else {
         /** @var $dataCollection \Magento\Core\Model\Resource\Config\Data\Collection */
         $dataCollection = $this->_configValueFactory->create()->getCollection();
         $dataCollection->addValueFilter(\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER);
         /** @var $data \Magento\Framework\App\Config\ValueInterface */
         foreach ($dataCollection as $data) {
             if ($data->getScope() == 'stores') {
                 $code = $this->_storeManager->getStore($data->getScopeId())->getCode();
                 $output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', array('section' => 'web', 'store' => $code));
                 break;
             } elseif ($data->getScope() == 'websites') {
                 $code = $this->_storeManager->getWebsite($data->getScopeId())->getCode();
                 $output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', array('section' => 'web', 'website' => $code));
                 break;
             }
         }
     }
     return $output;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:31,代码来源:Baseurl.php

示例6: getAddress

 /**
  * {@inheritdoc}
  */
 public function getAddress($cartId)
 {
     $storeId = $this->storeManager->getStore()->getId();
     /** @var  \Magento\Sales\Model\Quote\Address $address */
     $address = $this->quoteLoader->load($cartId, $storeId)->getBillingAddress();
     return $this->addressConverter->convertModelToDataObject($address);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:10,代码来源:ReadService.php

示例7: setMethod

 /**
  * {@inheritdoc}
  */
 public function setMethod($cartId, $carrierCode, $methodCode)
 {
     /** @var \Magento\Sales\Model\Quote $quote */
     $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId());
     if (0 == $quote->getItemsCount()) {
         throw new InputException('Shipping method is not applicable for empty cart');
     }
     if ($quote->isVirtual()) {
         throw new NoSuchEntityException('Cart contains virtual product(s) only. Shipping method is not applicable.');
     }
     $shippingAddress = $quote->getShippingAddress();
     if (!$shippingAddress->getCountryId()) {
         throw new StateException('Shipping address is not set');
     }
     $billingAddress = $quote->getBillingAddress();
     if (!$billingAddress->getCountryId()) {
         throw new StateException('Billing address is not set');
     }
     $shippingAddress->setShippingMethod($carrierCode . '_' . $methodCode);
     if (!$shippingAddress->requestShippingRates()) {
         throw new NoSuchEntityException('Carrier with such method not found: ' . $carrierCode . ', ' . $methodCode);
     }
     try {
         $quote->collectTotals()->save();
     } catch (\Exception $e) {
         throw new CouldNotSaveException('Cannot set shipping method. ' . $e->getMessage());
     }
     return true;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:32,代码来源:WriteService.php

示例8: testProcessWithoutStoreCode

 public function testProcessWithoutStoreCode()
 {
     $path = 'rest/V1/customerAccounts/createCustomer';
     $result = $this->pathProcessor->process($path);
     $this->assertEquals('/V1/customerAccounts/createCustomer', $result);
     $this->assertEquals('default', $this->storeManager->getStore()->getCode());
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:7,代码来源:PathProcessorTest.php

示例9: setAddress

 /**
  * {@inheritdoc}
  */
 public function setAddress($cartId, $addressData)
 {
     /** @var \Magento\Sales\Model\Quote $quote */
     $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId());
     if ($quote->isVirtual()) {
         throw new NoSuchEntityException('Cart contains virtual product(s) only. Shipping address is not applicable');
     }
     /** @var \Magento\Sales\Model\Quote\Address $address */
     $address = $this->quoteAddressFactory->create();
     $this->addressValidator->validate($addressData);
     if ($addressData->getId()) {
         $address->load($addressData->getId());
     }
     $address = $this->addressConverter->convertDataObjectToModel($addressData, $address);
     $address->setSameAsBilling(0);
     $quote->setShippingAddress($address);
     $quote->setDataChanges(true);
     try {
         $quote->save();
     } catch (\Exception $e) {
         $this->logger->logException($e);
         throw new InputException('Unable to save address. Please, check input data.');
     }
     return $quote->getShippingAddress()->getId();
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:28,代码来源:WriteService.php

示例10: 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

示例11: _isInternal

 /**
  * Check if URL is internal
  *
  * @param string $url
  * @return bool
  */
 protected function _isInternal($url)
 {
     if (strpos($url, 'http') === false) {
         return false;
     }
     $currentStore = $this->_storeManager->getStore();
     return strpos($url, $currentStore->getBaseUrl()) === 0 || strpos($url, $currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true)) === 0;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:14,代码来源:Price.php

示例12: getUrl

 /**
  * Return image url
  *
  * @param \Magento\Framework\Object $object
  * @return string|null
  */
 public function getUrl($object)
 {
     $url = false;
     if ($image = $object->getData($this->getAttribute()->getAttributeCode())) {
         $url = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . self::IMAGE_PATH_SEGMENT . $image;
     }
     return $url;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:14,代码来源:Image.php

示例13: _getUrl

 /**
  * @return bool|string
  */
 protected function _getUrl()
 {
     $url = false;
     if ($this->getValue()) {
         $url = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'catalog/category/' . $this->getValue();
     }
     return $url;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:11,代码来源:Image.php

示例14: getRequiredAgreementIds

 /**
  * Get list of required Agreement Ids
  *
  * @return int[]
  */
 public function getRequiredAgreementIds()
 {
     if (!$this->scopeConfig->isSetFlag(self::PATH_ENABLED, ScopeInterface::SCOPE_STORE)) {
         return [];
     } else {
         return $this->agreementCollectionFactory->create()->addStoreFilter($this->storeManager->getStore()->getId())->addFieldToFilter('is_active', 1)->getAllIds();
     }
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:13,代码来源:AgreementsProvider.php

示例15: getScope

 /**
  * {@inheritdoc}
  * @throws \Magento\Framework\App\InitException
  */
 public function getScope($scopeId = null)
 {
     $scope = $this->_storeManager->getStore($scopeId);
     if (!$scope instanceof \Magento\Framework\App\ScopeInterface) {
         throw new \Magento\Framework\App\InitException('Invalid scope object');
     }
     return $scope;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:12,代码来源:Store.php


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