本文整理匯總了PHP中Magento\Store\Model\Store類的典型用法代碼示例。如果您正苦於以下問題:PHP Store類的具體用法?PHP Store怎麽用?PHP Store使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Store類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testLoadValidOrderNotEmptyPost
public function testLoadValidOrderNotEmptyPost()
{
$post = ['oar_order_id' => 1, 'oar_type' => 'email', 'oar_billing_lastname' => 'oar_billing_lastname', 'oar_email' => 'oar_email', 'oar_zip' => 'oar_zip'];
$storeId = '1';
$incrementId = $post['oar_order_id'];
$protectedCode = 'protectedCode';
$this->sessionMock->expects($this->once())->method('isLoggedIn')->willReturn(false);
$requestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
$requestMock->expects($this->once())->method('getPostValue')->willReturn($post);
$this->storeManagerInterfaceMock->expects($this->once())->method('getStore')->willReturn($this->storeModelMock);
$this->storeModelMock->expects($this->once())->method('getId')->willReturn($storeId);
$this->orderFactoryMock->expects($this->once())->method('create')->willReturn($this->salesOrderMock);
$this->salesOrderMock->expects($this->once())->method('loadByIncrementIdAndStoreId')->willReturnSelf();
$this->salesOrderMock->expects($this->any())->method('getId')->willReturn($incrementId);
$billingAddressMock = $this->getMock('Magento\\Sales\\Model\\Order\\Address', ['getLastname', 'getEmail', '__wakeup'], [], '', false);
$billingAddressMock->expects($this->once())->method('getLastname')->willReturn($post['oar_billing_lastname']);
$billingAddressMock->expects($this->once())->method('getEmail')->willReturn($post['oar_email']);
$this->salesOrderMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddressMock);
$this->salesOrderMock->expects($this->once())->method('getProtectCode')->willReturn($protectedCode);
$metaDataMock = $this->getMock('Magento\\Framework\\Stdlib\\Cookie\\PublicCookieMetadata', [], [], '', false);
$metaDataMock->expects($this->once())->method('setPath')->with(Guest::COOKIE_PATH)->willReturnSelf();
$metaDataMock->expects($this->once())->method('setHttpOnly')->with(true)->willReturnSelf();
$this->cookieMetadataFactoryMock->expects($this->once())->method('createPublicCookieMetadata')->willReturn($metaDataMock);
$this->cookieManagerMock->expects($this->once())->method('setPublicCookie')->with(Guest::COOKIE_NAME, $this->anything(), $metaDataMock);
$this->assertTrue($this->guest->loadValidOrder($requestMock));
}
示例2: getCollection
/**
* @inheritdoc
*/
protected function getCollection(Store $store)
{
/** @var \Magento\Sales\Model\ResourceModel\Order\Collection $collection */
$collection = $this->_orderCollectionFactory->create();
$collection->addAttributeToFilter('store_id', ['eq' => $store->getId()]);
return $collection;
}
示例3: testGetTreeHasLevelField
public function testGetTreeHasLevelField()
{
$rootId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
$storeGroups = [];
$storeId = 1;
$rootLevel = 2;
$level = 3;
$this->collection->expects($this->any())->method('addAttributeToSelect')->willReturnMap([['url_key', false, $this->collection], ['is_anchor', false, $this->collection]]);
$this->childNode->expects($this->atLeastOnce())->method('getLevel')->willReturn($level);
$this->rootNode->expects($this->atLeastOnce())->method('getLevel')->willReturn($rootLevel);
$this->rootNode->expects($this->once())->method('hasChildren')->willReturn(true);
$this->rootNode->expects($this->once())->method('getChildren')->willReturn([$this->childNode]);
$this->categoryTree->expects($this->once())->method('load')->with(null, 3)->willReturnSelf();
$this->categoryTree->expects($this->atLeastOnce())->method('addCollectionData')->with($this->collection)->willReturnSelf();
$this->categoryTree->expects($this->once())->method('getNodeById')->with($rootId)->willReturn($this->rootNode);
$this->store->expects($this->atLeastOnce())->method('getId')->willReturn($storeId);
$this->storeManager->expects($this->once())->method('getGroups')->willReturn($storeGroups);
$this->storeManager->expects($this->atLeastOnce())->method('getStore')->willReturn($this->store);
$this->context->expects($this->once())->method('getStoreManager')->willReturn($this->storeManager);
$this->context->expects($this->once())->method('getRequest')->willReturn($this->request);
$this->context->expects($this->once())->method('getEscaper')->willReturn($this->escaper);
$this->context->expects($this->once())->method('getEventManager')->willReturn($this->eventManager);
/** @var \Magento\Widget\Block\Adminhtml\Widget\Catalog\Category\Chooser $chooser */
$chooser = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\Widget\\Block\\Adminhtml\\Widget\\Catalog\\Category\\Chooser', ['categoryTree' => $this->categoryTree, 'context' => $this->context]);
$chooser->setData('category_collection', $this->collection);
$result = $chooser->getTree();
$this->assertEquals($level, $result[0]['level']);
}
示例4: testTrimPathInfoForGetTargetStorePostData
public function testTrimPathInfoForGetTargetStorePostData()
{
$this->request->expects($this->once())->method('getPathInfo')->willReturn('path/with/trim/');
$this->store->expects($this->once())->method('getId')->willReturn(1);
$this->urlFinder->expects($this->once())->method('findOneByData')->with([\Magento\UrlRewrite\Service\V1\Data\UrlRewrite::TARGET_PATH => 'path/with/trim', \Magento\UrlRewrite\Service\V1\Data\UrlRewrite::STORE_ID => 1])->willReturn(null);
$this->urlHelper->expects($this->never())->method('getEncodedUrl');
$this->assertEquals([$this->store, []], $this->unit->beforeGetTargetStorePostData($this->switcher, $this->store, []));
}
示例5: __construct
/**
* @param \Magento\Store\Model\StoreFactory $storeFactory
* @param \Magento\Store\Model\WebsiteFactory $websiteFactory
* @param \Magento\Store\Model\GroupFactory $groupFactory
*/
public function __construct(\Magento\Store\Model\StoreFactory $storeFactory, \Magento\Store\Model\WebsiteFactory $websiteFactory, \Magento\Store\Model\GroupFactory $groupFactory)
{
$this->_store = $storeFactory->create();
$this->_store->setId(\Magento\Store\Model\Store::DISTRO_STORE_ID);
$this->_store->setCode(\Magento\Store\Model\Store::DEFAULT_CODE);
$this->_website = $websiteFactory->create();
$this->_group = $groupFactory->create();
}
示例6: clearIndex
/**
* @param \Magento\Store\Model\Store $store
* @return void
*/
private function clearIndex(\Magento\Store\Model\Store $store)
{
$dimensions = [$this->dimensionFactory->create(['name' => 'scope', 'value' => $store->getId()])];
$configData = $this->indexerConfig->getIndexer(FulltextIndexer::INDEXER_ID);
/** @var \Magento\CatalogSearch\Model\Indexer\IndexerHandler $indexHandler */
$indexHandler = $this->indexerHandlerFactory->create(['data' => $configData]);
$indexHandler->cleanIndex($dimensions);
}
示例7: getLogoImage
/**
* Get logo image
*
* @param \Magento\Store\Model\Store $store
* @return string|null
*/
public function getLogoImage($store)
{
$image = null;
if (null !== $store) {
$image = basename($this->_scopeConfig->getValue('design/header/logo_src', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store->getId()));
}
return $image;
}
示例8: testGetAllOptions
/**
* Test for getAllOptions method
*
* @param $cachedDataSrl
* @param $cachedDataUnsrl
*
* @dataProvider testGetAllOptionsDataProvider
*/
public function testGetAllOptions($cachedDataSrl, $cachedDataUnsrl)
{
$this->storeMock->expects($this->once())->method('getCode')->will($this->returnValue('store_code'));
$this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock));
$this->cacheConfig->expects($this->once())->method('load')->with($this->equalTo('COUNTRYOFMANUFACTURE_SELECT_STORE_store_code'))->will($this->returnValue($cachedDataSrl));
$countryOfManufacture = $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Product\\Attribute\\Source\\Countryofmanufacture', ['storeManager' => $this->storeManagerMock, 'configCacheType' => $this->cacheConfig]);
$this->assertEquals($cachedDataUnsrl, $countryOfManufacture->getAllOptions());
}
示例9: beforeGetTargetStorePostData
/**
* Set redirect url for store view based on request path info
*
* @param \Magento\Store\Block\Switcher $switcher
* @param \Magento\Store\Model\Store $store
* @param array $data
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeGetTargetStorePostData(\Magento\Store\Block\Switcher $switcher, \Magento\Store\Model\Store $store, $data = [])
{
$urlRewrite = $this->urlFinder->findOneByData([UrlRewrite::TARGET_PATH => $this->trimSlashInPath($this->request->getPathInfo()), UrlRewrite::STORE_ID => $store->getId()]);
if ($urlRewrite) {
$data[ActionInterface::PARAM_NAME_URL_ENCODED] = $this->urlHelper->getEncodedUrl($this->trimSlashInPath($this->urlBuilder->getUrl($urlRewrite->getRequestPath())));
}
return [$store, $data];
}
示例10: getCollection
/**
* @inheritdoc
*/
protected function getCollection(Store $store)
{
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
$collection = $this->_productCollectionFactory->create();
$collection->setVisibility($this->_productVisibility->getVisibleInSiteIds());
$collection->addAttributeToFilter('status', ['eq' => '1']);
$collection->addStoreFilter($store->getId());
return $collection;
}
示例11: aroundSave
/**
* Invalidate design config grid indexer on store creation
*
* @param StoreStore $subject
* @param \Closure $proceed
* @return StoreStore
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundSave(StoreStore $subject, \Closure $proceed)
{
$isObjectNew = $subject->getId() == 0;
$result = $proceed();
if ($isObjectNew) {
$this->indexerRegistry->get(Config::DESIGN_CONFIG_GRID_INDEXER_ID)->invalidate();
}
return $result;
}
示例12: testGetSwatchAttributeImage
/**
* @dataProvider dataForFullPath
*/
public function testGetSwatchAttributeImage($swatchType, $expectedResult)
{
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock);
$this->storeMock->expects($this->once())->method('getBaseUrl')->with('media')->willReturn('http://url/pub/media/');
$this->generateImageConfig();
$this->testGenerateSwatchVariations();
$result = $this->mediaHelperObject->getSwatchAttributeImage($swatchType, '/f/i/file.png');
$this->assertEquals($result, $expectedResult);
}
示例13: __construct
/**
* @param string $chunkId
* @param string $storeId
* @param string $processId
* @param \Magento\Framework\App\Console\Response $response
*/
public function __construct($chunkId, $storeId, $processId, \Celebros\Celexport\Helper\Export $helper, \Magento\Store\Model\Store $store, \Celebros\Celexport\Model\Cache $cache, \Magento\Framework\App\State $state, \Magento\Framework\ObjectManagerInterface $objectManager)
{
$this->_chunkId = $chunkId;
$this->_storeId = $storeId;
$this->_store = $store->load($this->_storeId);
$this->_cache = $cache;
$this->_processId = $processId;
$this->_state = $state;
$this->_objectManager = $objectManager;
$this->helper = $helper;
}
示例14: testGetWebsiteDefault
/**
* Tests that getWebsite returns the default site when defaults are passed in for id
*/
public function testGetWebsiteDefault()
{
$this->assertFalse($this->_model->getWebsite());
$website = Bootstrap::getObjectManager()->get('Magento\\Store\\Model\\StoreManagerInterface')->getWebsite();
$this->_model->setWebsite($website);
// Empty string should get treated like no parameter
$actualResult = $this->_model->getWebsite('');
$this->assertSame($website, $actualResult);
// Null string should get treated like no parameter
$actualResult = $this->_model->getWebsite(null);
$this->assertSame($website, $actualResult);
}
示例15: build
/**
* @param Store $store
* @return \NostoBilling
*/
public function build(Store $store)
{
$metaData = new \NostoBilling();
try {
$country = $store->getConfig('general/country/default');
if (!empty($country)) {
$metaData->setCountry(new \NostoCountryCode($country));
}
} catch (\NostoException $e) {
$this->_logger->error($e, ['exception' => $e]);
}
return $metaData;
}