本文整理汇总了PHP中Magento\Store\Model\Store类的典型用法代码示例。如果您正苦于以下问题:PHP Store类的具体用法?PHP Store怎么用?PHP Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Store类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:26,代码来源:GuestTest.php
示例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;
}
开发者ID:Nosto,项目名称:nosto-magento2,代码行数:10,代码来源:Order.php
示例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']);
}
开发者ID:nja78,项目名称:magento2,代码行数:28,代码来源:ChooserTest.php
示例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, []));
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:8,代码来源:SetRedirectUrlTest.php
示例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();
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:DefaultStorage.php
示例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);
}
开发者ID:nja78,项目名称:magento2,代码行数:12,代码来源:Store.php
示例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;
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:LogoUploader.php
示例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());
}
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:16,代码来源:CountryofmanufactureTest.php
示例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];
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:SetRedirectUrl.php
示例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;
}
开发者ID:Nosto,项目名称:nosto-magento2,代码行数:12,代码来源:Product.php
示例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;
}
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:17,代码来源:Store.php
示例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);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:MediaTest.php
示例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;
}
开发者ID:CelebrosLtd,项目名称:M2_Celexport,代码行数:17,代码来源:Export.php
示例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);
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:15,代码来源:GroupTest.php
示例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;
}
开发者ID:Nosto,项目名称:nosto-magento2,代码行数:17,代码来源:Builder.php
示例16: testGetStoreValuesForForm
/**
* @dataProvider getStoreValuesForFormDataProvider
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function testGetStoreValuesForForm($empty, $all, $storeId, $groupId, $websiteId, $storeName, $groupName, $websiteName, $storeGroupId, $groupWebsiteId, $expectedResult)
{
$this->websiteMock->expects($this->any())->method('getId')->willReturn($websiteId);
$this->websiteMock->expects($this->any())->method('getName')->willReturn($websiteName);
$this->groupMock->expects($this->any())->method('getId')->willReturn($groupId);
$this->groupMock->expects($this->any())->method('getName')->willReturn($groupName);
$this->groupMock->expects($this->any())->method('getWebsiteId')->willReturn($groupWebsiteId);
$this->storeMock->expects($this->any())->method('getId')->willReturn($storeId);
$this->storeMock->expects($this->any())->method('getName')->willReturn($storeName);
$this->storeMock->expects($this->any())->method('getGroupId')->willReturn($storeGroupId);
$this->model->setIsAdminScopeAllowed(true);
$this->assertEquals($this->model->getStoreValuesForForm($empty, $all), $expectedResult);
}
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:17,代码来源:StoreTest.php
示例17: getRequestPathByIdPath
/**
* Retrieve request_path using id_path and current store's id.
*
* @param string $idPath
* @param int|\Magento\Store\Model\Store $store
* @return string
*/
public function getRequestPathByIdPath($idPath, $store)
{
if ($store instanceof \Magento\Store\Model\Store) {
$storeId = (int) $store->getId();
} else {
$storeId = (int) $store;
}
$select = $this->_getReadAdapter()->select();
/** @var $select \Magento\Framework\DB\Select */
$select->from(array('main_table' => $this->getMainTable()), 'request_path')->where('main_table.store_id = :store_id')->where('main_table.id_path = :id_path')->limit(1);
$bind = array('store_id' => $storeId, 'id_path' => $idPath);
return $this->_getReadAdapter()->fetchOne($select, $bind);
}
开发者ID:aiesh,项目名称:magento2,代码行数:20,代码来源:UrlRewrite.php
示例18: testNewAccount
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testNewAccount()
{
$customerId = 1;
$customerStoreId = 2;
$customerEmail = '[email protected]';
$customerData = ['key' => 'value'];
$customerName = 'Customer Name';
$templateIdentifier = 'Template Identifier';
$sender = 'Sender';
$customer = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false);
$customer->expects($this->any())->method('getStoreId')->willReturn($customerStoreId);
$customer->expects($this->any())->method('getId')->willReturn($customerId);
$customer->expects($this->any())->method('getEmail')->willReturn($customerEmail);
$this->storeMock->expects($this->any())->method('getId')->willReturn($customerStoreId);
$this->storeManagerMock->expects($this->once())->method('getStore')->with($customerStoreId)->willReturn($this->storeMock);
$this->customerRegistryMock->expects($this->once())->method('retrieveSecureData')->with($customerId)->willReturn($this->customerSecureMock);
$this->dataProcessorMock->expects($this->once())->method('buildOutputDataArray')->with($customer, \Magento\Customer\Api\Data\CustomerInterface::class)->willReturn($customerData);
$this->customerViewHelperMock->expects($this->any())->method('getCustomerName')->with($customer)->willReturn($customerName);
$this->customerSecureMock->expects($this->once())->method('addData')->with($customerData)->willReturnSelf();
$this->customerSecureMock->expects($this->once())->method('setData')->with('name', $customerName)->willReturnSelf();
$this->scopeConfigMock->expects($this->at(0))->method('getValue')->with(EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $customerStoreId)->willReturn($templateIdentifier);
$this->scopeConfigMock->expects($this->at(1))->method('getValue')->with(EmailNotification::XML_PATH_REGISTER_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId)->willReturn($sender);
$transport = $this->getMock(\Magento\Framework\Mail\TransportInterface::class, [], [], '', false);
$this->transportBuilderMock->expects($this->once())->method('setTemplateIdentifier')->with($templateIdentifier)->willReturnSelf();
$this->transportBuilderMock->expects($this->once())->method('setTemplateOptions')->with(['area' => Area::AREA_FRONTEND, 'store' => $customerStoreId])->willReturnSelf();
$this->transportBuilderMock->expects($this->once())->method('setTemplateVars')->with(['customer' => $this->customerSecureMock, 'back_url' => '', 'store' => $this->storeMock])->willReturnSelf();
$this->transportBuilderMock->expects($this->once())->method('setFrom')->with($sender)->willReturnSelf();
$this->transportBuilderMock->expects($this->once())->method('addTo')->with($customerEmail, $customerName)->willReturnSelf();
$this->transportBuilderMock->expects($this->once())->method('getTransport')->willReturn($transport);
$transport->expects($this->once())->method('sendMessage');
$this->model->newAccount($customer, EmailNotification::NEW_ACCOUNT_EMAIL_REGISTERED, '', $customerStoreId);
}
开发者ID:Doability,项目名称:magento2dev,代码行数:35,代码来源:EmailNotificationTest.php
示例19: testSaveValidation
/**
* @param array $badStoreData
*
* @dataProvider saveValidationDataProvider
* @magentoAppIsolation enabled
* @magentoAppArea adminhtml
* @magentoDbIsolation enabled
* @expectedException \Magento\Framework\Exception\LocalizedException
*/
public function testSaveValidation($badStoreData)
{
$normalStoreData = ['code' => 'test', 'website_id' => 1, 'group_id' => 1, 'name' => 'test name', 'sort_order' => 0, 'is_active' => 1];
$data = array_merge($normalStoreData, $badStoreData);
$this->model->setData($data);
$this->model->save();
}
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:StoreTest.php
示例20: 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
注:本文中的Magento\Store\Model\Store类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论