• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Model\StoreManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testGetSwatchMediaUrl

 public function testGetSwatchMediaUrl()
 {
     $storeMock = $this->getMock('\\Magento\\Store\\Model\\Store', ['getBaseUrl'], [], '', false);
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
     $storeMock->expects($this->once())->method('getBaseUrl')->with('media')->willReturn('http://url/pub/media/');
     $result = $this->mediaHelperObject->getSwatchMediaUrl();
     $this->assertEquals($result, 'http://url/pub/media/attribute/swatch');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:MediaTest.php


示例17: testAroundDispatchNoStoreCookie

 public function testAroundDispatchNoStoreCookie()
 {
     $storeCode = null;
     $this->storeManagerMock->expects($this->once())->method('getDefaultStoreView')->willReturn($this->storeMock);
     $this->storeCookieManagerMock->expects($this->once())->method('getStoreCodeFromCookie')->willReturn($storeCode);
     $this->storeRepositoryMock->expects($this->never())->method('getActiveStoreByCode');
     $this->storeCookieManagerMock->expects($this->never())->method('deleteStoreCookie')->with($this->storeMock);
     $this->assertEquals('ExpectedValue', $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock));
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:9,代码来源:StoreCookieTest.php


示例18: testBeforeDispatchNoStoreCookie

 public function testBeforeDispatchNoStoreCookie()
 {
     $storeCode = null;
     $this->storeCookieManagerMock->expects($this->once())->method('getStoreCodeFromCookie')->willReturn($storeCode);
     $this->storeManagerMock->expects($this->never())->method('getDefaultStoreView')->willReturn($this->storeMock);
     $this->storeRepositoryMock->expects($this->never())->method('getActiveStoreByCode');
     $this->storeCookieManagerMock->expects($this->never())->method('deleteStoreCookie')->with($this->storeMock);
     $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock);
 }
开发者ID:vv-team,项目名称:foodo,代码行数:9,代码来源:StoreCookieTest.php


示例19: testSendNewAccountEmailWithoutStoreId

 public function testSendNewAccountEmailWithoutStoreId()
 {
     $store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $website = $this->getMock('Magento\\Store\\Model\\Website', [], [], '', false);
     $website->expects($this->once())->method('getStoreIds')->will($this->returnValue([1, 2, 3, 4]));
     $this->_storeManager->expects($this->once())->method('getWebsite')->with(1)->will($this->returnValue($website));
     $this->_storeManager->expects($this->once())->method('getStore')->with(1)->will($this->returnValue($store));
     $this->_config->expects($this->exactly(3))->method('getAttribute')->will($this->returnValue($this->_attribute));
     $this->_attribute->expects($this->exactly(3))->method('getIsVisible')->will($this->returnValue(true));
     $methods = ['setTemplateIdentifier', 'setTemplateOptions', 'setTemplateVars', 'setFrom', 'addTo'];
     foreach ($methods as $method) {
         $this->_transportBuilderMock->expects($this->once())->method($method)->will($this->returnSelf());
     }
     $transportMock = $this->getMock('Magento\\Framework\\Mail\\TransportInterface', [], [], '', false);
     $transportMock->expects($this->once())->method('sendMessage')->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('getTransport')->will($this->returnValue($transportMock));
     $this->_model->setData(['website_id' => 1, 'store_id' => 1, 'email' => '[email protected]', 'firstname' => 'FirstName', 'lastname' => 'LastName', 'middlename' => 'MiddleName', 'prefix' => 'Prefix']);
     $this->_model->sendNewAccountEmail('registered');
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:CustomerTest.php


示例20: execute

 /**
  * Execute method.
  */
 public function execute()
 {
     $code = $this->getRequest()->getParam('code', false);
     $userId = $this->getRequest()->getParam('state');
     //load admin user
     $adminUser = $this->adminUser->create()->load($userId);
     //app code and admin user must be present
     if ($code && $adminUser->getId()) {
         $clientId = $this->scopeConfig->getValue(\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CLIENT_ID);
         $clientSecret = $this->scopeConfig->getValue(\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CLIENT_SECRET_ID);
         //callback uri if not set custom
         $redirectUri = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true);
         $redirectUri .= 'connector/email/callback';
         $data = 'client_id=' . $clientId . '&client_secret=' . $clientSecret . '&redirect_uri=' . $redirectUri . '&grant_type=authorization_code' . '&code=' . $code;
         //callback url
         $url = $this->config->getTokenUrl();
         //@codingStandardsIgnoreStart
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
         curl_setopt($ch, CURLOPT_POST, count($data));
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
         curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']);
         $response = json_decode(curl_exec($ch));
         if ($response === false) {
             $this->helper->error('Error Number: ' . curl_errno($ch), []);
         }
         if (isset($response->error)) {
             $this->helper->error('OAUTH failed ' . $response->error, []);
         } elseif (isset($response->refresh_token)) {
             //save the refresh token to the admin user
             $adminUser->setRefreshToken($response->refresh_token)->save();
         }
         //@codingStandardsIgnoreEnd
     }
     //redirect to automation index page
     $this->_redirect($this->adminHelper->getUrl('dotdigitalgroup_email/studio'));
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:45,代码来源:Callback.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Model\StoreManagerInterface类代码示例发布时间:2022-05-23
下一篇:
PHP Model\Store类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap