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


PHP Model\StoreManager类代码示例

本文整理汇总了PHP中Magento\Store\Model\StoreManager的典型用法代码示例。如果您正苦于以下问题:PHP StoreManager类的具体用法?PHP StoreManager怎么用?PHP StoreManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testIsSingleStoreModeWhenSingleStoreModeDisabledAndHasSingleStore

 public function testIsSingleStoreModeWhenSingleStoreModeDisabledAndHasSingleStore()
 {
     $this->_configMock->expects($this->once())->method('getValue')->with(\Magento\Store\Model\StoreManager::XML_PATH_SINGLE_STORE_MODE_ENABLED, \Magento\Framework\Store\ScopeInterface::SCOPE_STORE)->will($this->returnValue(false));
     $this->_storage->expects($this->once())->method('hasSingleStore')->will($this->returnValue(true));
     $this->_factoryMock->expects($this->any())->method('get')->will($this->returnValue($this->_storage));
     $this->assertFalse($this->_model->isSingleStoreMode());
 }
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:7,代码来源:StoreManagerTest.php

示例2: __construct

 public function __construct(Context $context, array $data = [], StoreManager $sManager, Webtracking $webtracking, Session $session)
 {
     parent::__construct($context, $data);
     $this->_activeStore = $sManager->getStore();
     $this->_webtracking = $webtracking;
     $this->_session = $session;
 }
开发者ID:remarkety,项目名称:mgconnector,代码行数:7,代码来源:Base.php

示例3: __construct

 public function __construct(Session $customerSession, CheckoutSession $CheckoutSession, Registry $registry, Subscriber $subscriber, Group $customerGroupModel, Queue $remarketyQueue, Store $store, ScopeConfigInterface $scopeConfig, StoreManager $sManager)
 {
     parent::__construct($registry, $subscriber, $customerGroupModel, $remarketyQueue, $store, $scopeConfig);
     $this->session = $customerSession;
     $this->_checkoutSession = $CheckoutSession;
     $this->_store = $sManager->getStore();
 }
开发者ID:remarkety,项目名称:mgconnector,代码行数:7,代码来源:TriggerSubscribeUpdateObserver.php

示例4: 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;
 }
开发者ID:praxigento,项目名称:mobi_app_generic_mage2,代码行数:43,代码来源:Stocks.php

示例5: setUp

 /**
  * Set up
  */
 public function setUp()
 {
     $this->sessionMock = $this->getMock('Magento\\Framework\\Session\\Generic', ['getCurrencyCode'], [], '', false);
     $this->httpContextMock = $this->getMock('Magento\\Framework\\App\\Http\\Context', [], [], '', false);
     $this->httpRequestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', ['getParam'], [], '', false);
     $this->storeManager = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface');
     $this->storeCookieManager = $this->getMock('Magento\\Store\\Api\\StoreCookieManagerInterface');
     $this->storeMock = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $this->currentStoreMock = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $this->websiteMock = $this->getMock('Magento\\Store\\Model\\Website', ['getDefaultStore', '__wakeup'], [], '', false);
     $this->closureMock = function () {
         return 'ExpectedValue';
     };
     $this->subjectMock = $this->getMock('Magento\\Framework\\App\\Action\\Action', [], [], '', false);
     $this->requestMock = $this->getMock('Magento\\Framework\\App\\RequestInterface');
     $this->plugin = (new ObjectManager($this))->getObject('Magento\\Store\\App\\Action\\Plugin\\Context', ['session' => $this->sessionMock, 'httpContext' => $this->httpContextMock, 'httpRequest' => $this->httpRequestMock, 'storeManager' => $this->storeManager, 'storeCookieManager' => $this->storeCookieManager]);
     $this->storeManager->expects($this->once())->method('getWebsite')->will($this->returnValue($this->websiteMock));
     $this->storeManager->method('getDefaultStoreView')->willReturn($this->storeMock);
     $this->storeManager->method('getStore')->willReturn($this->currentStoreMock);
     $this->websiteMock->expects($this->once())->method('getDefaultStore')->will($this->returnValue($this->storeMock));
     $this->storeMock->expects($this->once())->method('getDefaultCurrencyCode')->will($this->returnValue(self::CURRENCY_DEFAULT));
     $this->storeMock->expects($this->once())->method('getCode')->willReturn('default');
     $this->currentStoreMock->expects($this->once())->method('getCode')->willReturn('custom_store');
     $this->storeCookieManager->expects($this->once())->method('getStoreCodeFromCookie')->will($this->returnValue('storeCookie'));
     $this->httpRequestMock->expects($this->once())->method('getParam')->with($this->equalTo('___store'))->will($this->returnValue('default'));
     $this->currentStoreMock->expects($this->any())->method('getDefaultCurrencyCode')->will($this->returnValue(self::CURRENCY_CURRENT_STORE));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:30,代码来源:ContextTest.php

示例6: initContextMock

 /**
  * Create mock object for context
  */
 private function initContextMock()
 {
     $this->store = $this->getMockBuilder(Store::class)->disableOriginalConstructor()->setMethods(['getId', '__wakeup'])->getMock();
     $this->storeManager = $this->getMockBuilder(StoreManager::class)->disableOriginalConstructor()->setMethods(['getStore', '__wakeup'])->getMock();
     $this->storeManager->expects(static::any())->method('getStore')->willReturn($this->store);
     $this->urlBuilder = $this->getMockBuilder('Magento\\Framework\\UrlInterface')->getMockForAbstractClass();
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->getMockForAbstractClass();
     $this->context = $this->getMockBuilder('Magento\\Framework\\View\\Element\\Template\\Context')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
     $this->context->expects($this->any())->method('getUrlBuilder')->willReturn($this->urlBuilder);
     $this->context->expects($this->any())->method('getStoreManager')->willReturn($this->storeManager);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:ReviewTest.php

示例7: testDispatchStoreParameterIsArray

 public function testDispatchStoreParameterIsArray()
 {
     $this->storeMock->expects($this->once())->method('getDefaultCurrencyCode')->will($this->returnValue(self::CURRENCY_DEFAULT));
     $this->storeMock->expects($this->once())->method('getCode')->willReturn('default');
     $this->currentStoreMock->expects($this->once())->method('getCode')->willReturn('custom_store');
     $store = ['_data' => ['code' => 500]];
     $this->httpRequestMock->expects($this->once())->method('getParam')->with($this->equalTo('___store'))->will($this->returnValue($store));
     $this->storeManager->expects($this->once())->method('getStore')->with('500')->willReturn($this->currentStoreMock);
     $this->httpContextMock->expects($this->at(0))->method('setValue')->with(StoreManagerInterface::CONTEXT_STORE, 'custom_store', 'default');
     /** Make sure that current currency is taken from current store if no value is provided in session */
     $this->httpContextMock->expects($this->at(1))->method('setValue')->with(Context::CONTEXT_CURRENCY, self::CURRENCY_CURRENT_STORE, self::CURRENCY_DEFAULT);
     $result = $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock);
     $this->assertEquals('ExpectedValue', $result);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:ContextTest.php

示例8: getValue

 /**
  * Returns catalog rule value
  *
  * @return float|boolean
  */
 public function getValue()
 {
     if (null === $this->value) {
         $this->value = $this->resourceRuleFactory->create()->getRulePrice($this->dateTime->scopeTimeStamp($this->storeManager->getStore()->getId()), $this->storeManager->getStore()->getWebsiteId(), $this->customerSession->getCustomerGroupId(), $this->product->getId());
         $this->value = $this->value ? floatval($this->value) : false;
     }
     return $this->value;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:CatalogRulePrice.php

示例9: deleteExpiredImages

 /**
  * Delete Expired Captcha Images
  *
  * @return \Magento\Captcha\Model\Observer
  */
 public function deleteExpiredImages()
 {
     foreach ($this->_storeManager->getWebsites() as $website) {
         $this->_deleteExpiredImagesForWebsite($this->_helper, $website, $website->getDefaultStore());
     }
     $this->_deleteExpiredImagesForWebsite($this->_adminHelper);
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:Cron.php

示例10: testGetRelayUrl

 public function testGetRelayUrl()
 {
     $baseUrl = 'http://base.url/';
     $defaultStoreMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $defaultStoreMock->expects($this->once())->method('getBaseUrl')->with(\Magento\Framework\UrlInterface::URL_TYPE_LINK)->willReturn($baseUrl);
     $this->storeManagerMock->expects($this->once())->method('getDefaultStoreView')->willReturn(null);
     $this->storeManagerMock->expects($this->once())->method('getStores')->willReturn([$defaultStoreMock]);
     $this->assertSame('http://base.url/authorizenet/directpost_payment/backendResponse', $this->dataHelper->getRelayUrl());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:DataTest.php

示例11: getAllUrls

 /**
  * Get urls of all the stores in the magento install.
  *
  * @return array
  */
 public function getAllUrls()
 {
     $urls = [];
     $stores = $this->storeManager->getStores(false);
     foreach ($stores as $store) {
         $urls[] = $store->getBaseUrl();
     }
     return $urls;
 }
开发者ID:eonsequeira,项目名称:HS_All,代码行数:14,代码来源:Data.php

示例12: testGetPreviewImageUrl

 public function testGetPreviewImageUrl()
 {
     /** @var $theme \Magento\Theme\Model\Theme|\PHPUnit_Framework_MockObject_MockObject */
     $theme = $this->getMock('Magento\\Theme\\Model\\Theme', ['getPreviewImage', 'isPhysical', '__wakeup'], [], '', false);
     $theme->expects($this->any())->method('getPreviewImage')->will($this->returnValue('image.png'));
     $store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $store->expects($this->any())->method('getBaseUrl')->will($this->returnValue('http://localhost/'));
     $this->_storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
     $this->assertEquals('http://localhost/theme/preview/image.png', $this->model->getPreviewImageUrl($theme));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:PathTest.php

示例13: testGetStoreId

 /**
  * @dataProvider getStoreDataProvider
  * @param $websiteId
  * @param $websiteStoreId
  * @param $storeId
  * @param $result
  */
 public function testGetStoreId($websiteId, $websiteStoreId, $storeId, $result)
 {
     if ($websiteId * 1) {
         $this->_model->setWebsiteId($websiteId);
         $website = new \Magento\Framework\DataObject(['store_ids' => [$websiteStoreId]]);
         $this->_storeManager->expects($this->once())->method('getWebsite')->will($this->returnValue($website));
     } else {
         $this->_model->setStoreId($storeId);
         $this->_storeManager->expects($this->never())->method('getWebsite');
     }
     $this->assertEquals($result, $this->_model->getStoreId());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:CustomerTest.php

示例14: getValue

 /**
  * Returns catalog rule value
  *
  * @return float|boolean
  */
 public function getValue()
 {
     if (null === $this->value) {
         if ($this->product->hasData(self::PRICE_CODE)) {
             $this->value = floatval($this->product->getData(self::PRICE_CODE)) ?: false;
         } else {
             $this->value = $this->getRuleResource()->getRulePrice($this->dateTime->scopeDate($this->storeManager->getStore()->getId()), $this->storeManager->getStore()->getWebsiteId(), $this->customerSession->getCustomerGroupId(), $this->product->getId());
             $this->value = $this->value ? floatval($this->value) : false;
             if ($this->value) {
                 $this->value = $this->priceCurrency->convertAndRound($this->value);
             }
         }
     }
     return $this->value;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:20,代码来源:CatalogRulePrice.php

示例15: save

 /**
  * {@inheritdoc}
  */
 public function save(\Magento\Catalog\Api\Data\ProductInterface $product, \Magento\Bundle\Api\Data\OptionInterface $option)
 {
     $option->setStoreId($this->storeManager->getStore()->getId());
     $option->setParentId($product->getId());
     $optionId = $option->getOptionId();
     $linksToAdd = [];
     if (!$optionId) {
         $option->setDefaultTitle($option->getTitle());
         if (is_array($option->getProductLinks())) {
             $linksToAdd = $option->getProductLinks();
         }
     } else {
         $optionCollection = $this->type->getOptionsCollection($product);
         /** @var \Magento\Bundle\Model\Option $existingOption */
         $existingOption = $optionCollection->getItemById($option->getOptionId());
         if (!isset($existingOption) || !$existingOption->getOptionId()) {
             throw new NoSuchEntityException(__('Requested option doesn\'t exist'));
         }
         $option->setData(array_merge($existingOption->getData(), $option->getData()));
         $this->updateOptionSelection($product, $option);
     }
     try {
         $this->optionResource->save($option);
     } catch (\Exception $e) {
         throw new CouldNotSaveException(__('Could not save option'), $e);
     }
     /** @var \Magento\Bundle\Api\Data\LinkInterface $linkedProduct */
     foreach ($linksToAdd as $linkedProduct) {
         $this->linkManagement->addChild($product, $option->getOptionId(), $linkedProduct);
     }
     return $option->getOptionId();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:35,代码来源:OptionRepository.php


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