コード例 #1
0
ファイル: Website.php プロジェクト: Doability/magento2dev
 /**
  * Invalidate design config grid indexer on website creation
  *
  * @param StoreWebsite $subject
  * @param \Closure $proceed
  * @return StoreWebsite
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundSave(StoreWebsite $subject, \Closure $proceed)
 {
     $isObjectNew = $subject->getId() == 0;
     $result = $proceed();
     if ($isObjectNew) {
         $this->indexerRegistry->get(Config::DESIGN_CONFIG_GRID_INDEXER_ID)->invalidate();
     }
     return $result;
 }
コード例 #2
0
 /**
  * @param \Magento\Store\Model\Website $subject
  * @param \Magento\Store\Model\Store $store
  * @return \Magento\Store\Model\Store
  */
 public function afterGetDefaultStore(Website $subject, Store $store)
 {
     if ($this->generalConfig->isAvailable() && $this->storeSwitcher->isInitialized()) {
         $storeId = $this->storeSwitcher->getStoreId();
         if ($store->getId() != $storeId && in_array($storeId, $subject->getStoreIds())) {
             $store = $this->storeRepository->getById($storeId);
         }
     }
     return $store;
 }
コード例 #3
0
 /**
  * Test aroundDispatch
  */
 public function testAroundDispatch()
 {
     $this->storeManagerMock->expects($this->exactly(2))->method('getWebsite')->will($this->returnValue($this->websiteMock));
     $this->websiteMock->expects($this->exactly(2))->method('getDefaultStore')->will($this->returnValue($this->storeMock));
     $this->storeMock->expects($this->once())->method('getDefaultCurrency')->will($this->returnValue($this->currencyMock));
     $this->storeMock->expects($this->once())->method('getStoreCodeFromCookie')->will($this->returnValue('storeCookie'));
     $this->currencyMock->expects($this->once())->method('getCode')->will($this->returnValue('UAH'));
     $this->sessionMock->expects($this->once())->method('getCurrencyCode')->will($this->returnValue('UAH'));
     $this->httpRequestMock->expects($this->once())->method('getParam')->with($this->equalTo('___store'))->will($this->returnValue('default'));
     $this->httpContextMock->expects($this->atLeastOnce())->method('setValue')->will($this->returnValueMap([[\Magento\Core\Helper\Data::CONTEXT_CURRENCY, 'UAH', 'UAH', $this->httpContextMock], [\Magento\Core\Helper\Data::CONTEXT_STORE, 'default', 'default', $this->httpContextMock]]));
     $this->assertEquals('ExpectedValue', $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock));
 }
コード例 #4
0
 /**
  * @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);
 }
コード例 #5
0
 /**
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testSendPasswordResetConfirmationEmail()
 {
     $storeId = 1;
     $storeIds = array(1);
     $email = '*****@*****.**';
     $firstName = 'Foo';
     $lastName = 'Bar';
     $this->_model->setStoreId(0);
     $this->_model->setWebsiteId(1);
     $this->_model->setEmail($email);
     $this->_model->setFirstname($firstName);
     $this->_model->setLastname($lastName);
     $this->_config->expects($this->any())->method('getAttribute')->will($this->returnValue($this->_attribute));
     $this->_attribute->expects($this->any())->method('isVisible')->will($this->returnValue(false));
     $this->_storeManager->expects($this->once())->method('getWebsite')->with($this->equalTo(1))->will($this->returnValue($this->_website));
     $this->_storeManager->expects($this->once())->method('getStore')->with(0)->will($this->returnValue($this->_storetMock));
     $this->_website->expects($this->once())->method('getStoreIds')->will($this->returnValue($storeIds));
     $this->_scopeConfigMock->expects($this->at(0))->method('getValue')->with(\Magento\Customer\Model\Customer::XML_PATH_RESET_PASSWORD_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId)->will($this->returnValue('templateId'));
     $this->_scopeConfigMock->expects($this->at(1))->method('getValue')->with(\Magento\Customer\Model\Customer::XML_PATH_FORGOT_EMAIL_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId)->will($this->returnValue('sender'));
     $this->_transportBuilderMock->expects($this->once())->method('setTemplateOptions')->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('setTemplateVars')->with(array('customer' => $this->_model, 'store' => $this->_storetMock))->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('addTo')->with($this->equalTo($email), $this->equalTo($firstName . ' ' . $lastName))->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('setFrom')->with('sender')->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('setTemplateIdentifier')->with('templateId')->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('getTransport')->will($this->returnValue($this->_transportMock));
     $this->_transportMock->expects($this->once())->method('sendMessage');
     $this->_model->sendPasswordResetNotificationEmail();
 }
コード例 #6
0
 /**
  * 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));
 }
コード例 #7
0
 protected function setUp()
 {
     $this->objectManager = new ObjectManager($this);
     $this->assignedWebsites = [self::SECOND_WEBSITE_ID];
     $this->websiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->setMethods(['getId', 'getName'])->disableOriginalConstructor()->getMock();
     $this->secondWebsiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->setMethods(['getId', 'getName'])->disableOriginalConstructor()->getMock();
     $this->websiteRepositoryMock = $this->getMockBuilder('Magento\\Store\\Api\\WebsiteRepositoryInterface')->setMethods(['getList', 'getDefault'])->getMockForAbstractClass();
     $this->websiteRepositoryMock->expects($this->any())->method('getDefault')->willReturn($this->websiteMock);
     $this->websiteRepositoryMock->expects($this->any())->method('getList')->willReturn([$this->websiteMock, $this->secondWebsiteMock]);
     $this->groupRepositoryMock = $this->getMockBuilder('Magento\\Store\\Api\\GroupRepositoryInterface')->setMethods(['getList'])->getMockForAbstractClass();
     $this->storeRepositoryMock = $this->getMockBuilder('Magento\\Store\\Api\\StoreRepositoryInterface')->setMethods(['getList'])->getMockForAbstractClass();
     $this->locatorMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Locator\\LocatorInterface')->setMethods(['getProduct', 'getWebsiteIds'])->getMockForAbstractClass();
     $this->productMock = $this->getMockBuilder('Magento\\Catalog\\Api\\Data\\ProductInterface')->setMethods(['getId'])->getMockForAbstractClass();
     $this->locatorMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
     $this->locatorMock->expects($this->any())->method('getWebsiteIds')->willReturn($this->assignedWebsites);
     $this->storeManagerMock = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->setMethods(['isSingleStoreMode'])->getMockForAbstractClass();
     $this->storeManagerMock->expects($this->any())->method('isSingleStoreMode')->willReturn(false);
     $this->groupMock = $this->getMockBuilder('Magento\\Store\\Model\\ResourceModel\\Group\\Collection')->setMethods(['getId', 'getName', 'getWebsiteId'])->disableOriginalConstructor()->getMock();
     $this->groupMock->expects($this->any())->method('getWebsiteId')->willReturn(self::WEBSITE_ID);
     $this->groupMock->expects($this->any())->method('getId')->willReturn(self::GROUP_ID);
     $this->groupRepositoryMock->expects($this->any())->method('getList')->willReturn([$this->groupMock]);
     $this->storeViewMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->setMethods(['getName', 'getId', 'getStoreGroupId'])->disableOriginalConstructor()->getMock();
     $this->storeViewMock->expects($this->any())->method('getName')->willReturn(self::STORE_VIEW_NAME);
     $this->storeViewMock->expects($this->any())->method('getStoreGroupId')->willReturn(self::GROUP_ID);
     $this->storeViewMock->expects($this->any())->method('getId')->willReturn(self::STORE_VIEW_ID);
     $this->storeRepositoryMock->expects($this->any())->method('getList')->willReturn([$this->storeViewMock]);
     $this->productMock->expects($this->any())->method('getId')->willReturn(self::PRODUCT_ID);
     $this->secondWebsiteMock->expects($this->any())->method('getId')->willReturn($this->assignedWebsites[0]);
     $this->websiteMock->expects($this->any())->method('getId')->willReturn(self::WEBSITE_ID);
 }
コード例 #8
0
ファイル: Switcher.php プロジェクト: aiesh/magento2
 /**
  * Process website info
  *
  * @param \Magento\Store\Model\System\Store $storeModel
  * @param \Magento\Store\Model\Website $website
  * @param string $section
  * @param string $curStore
  * @param string $curWebsite
  * @param array $options
  * @return array
  */
 protected function _processWebsite(\Magento\Store\Model\System\Store $storeModel, \Magento\Store\Model\Website $website, $section, $curStore, $curWebsite, array $options)
 {
     $websiteShow = false;
     foreach ($storeModel->getGroupCollection() as $group) {
         if ($group->getWebsiteId() != $website->getId()) {
             continue;
         }
         $groupShow = false;
         foreach ($storeModel->getStoreCollection() as $store) {
             if ($store->getGroupId() != $group->getId()) {
                 continue;
             }
             if (!$websiteShow) {
                 $websiteShow = true;
                 $options['website_' . $website->getCode()] = array('label' => $website->getName(), 'url' => $this->getUrl('*/*/*', array('section' => $section, 'website' => $website->getCode())), 'selected' => !$curStore && $curWebsite == $website->getCode(), 'style' => 'padding-left:16px; background:#DDD; font-weight:bold;');
             }
             if (!$groupShow) {
                 $groupShow = true;
                 $options['group_' . $group->getId() . '_open'] = array('is_group' => true, 'is_close' => false, 'label' => $group->getName(), 'style' => 'padding-left:32px;');
             }
             $options['store_' . $store->getCode()] = array('label' => $store->getName(), 'url' => $this->getUrl('*/*/*', array('section' => $section, 'website' => $website->getCode(), 'store' => $store->getCode())), 'selected' => $curStore == $store->getCode(), 'style' => '');
         }
         if ($groupShow) {
             $options['group_' . $group->getId() . '_close'] = array('is_group' => true, 'is_close' => true);
         }
     }
     return $options;
 }
コード例 #9
0
ファイル: ProductTest.php プロジェクト: opexsw/magento2
 public function testGetStoreIds()
 {
     $expectedStoreIds = [1, 2, 3];
     $websiteIds = ['test'];
     $this->resource->expects($this->once())->method('getWebsiteIds')->will($this->returnValue($websiteIds));
     $this->website->expects($this->once())->method('getStoreIds')->will($this->returnValue($expectedStoreIds));
     $this->assertEquals($expectedStoreIds, $this->model->getStoreIds());
 }
コード例 #10
0
 /**
  * {@inheritdoc}
  */
 public function delete()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'delete');
     if (!$pluginInfo) {
         return parent::delete();
     } else {
         return $this->___callPlugins('delete', func_get_args(), $pluginInfo);
     }
 }
コード例 #11
0
 /**
  * Get loaded websites
  *
  * @param bool $withDefault
  * @param bool|string $codeKey
  * @return \Magento\Store\Model\Website[]
  */
 public function getWebsites($withDefault = false, $codeKey = false)
 {
     $websites = [];
     if ($withDefault) {
         $key = $codeKey ? $this->_website->getCode() : $this->_website->getId();
         $websites[$key] = $this->_website;
     }
     return $websites;
 }
コード例 #12
0
 /**
  * @param \Magento\Store\Model\WebsiteRepository $subject
  * @param \Magento\Store\Model\Website $website
  * @return \Magento\Store\Model\Website
  */
 public function afterGetDefault(WebsiteRepository $subject, Website $website)
 {
     if (!$this->isNeededProcess()) {
         return $website;
     }
     if ($this->geoWebsite->getId() != $website->getId()) {
         $website = $subject->getById($this->geoWebsite->getId());
     }
     return $website;
 }
コード例 #13
0
ファイル: OptionsTest.php プロジェクト: tingyeeh/magento2
 public function testToOptionArray()
 {
     $websiteCollection = [$this->websiteMock];
     $groupCollection = [$this->groupMock];
     $storeCollection = [$this->storeMock];
     $expectedOptions = [['label' => __('All Store Views'), 'value' => '0'], ['label' => 'Main Website', 'value' => [['label' => '    Main Website Store', 'value' => [['label' => '        Default Store View', 'value' => '1']]]]]];
     $this->systemStoreMock->expects($this->once())->method('getWebsiteCollection')->willReturn($websiteCollection);
     $this->systemStoreMock->expects($this->once())->method('getGroupCollection')->willReturn($groupCollection);
     $this->systemStoreMock->expects($this->once())->method('getStoreCollection')->willReturn($storeCollection);
     $this->websiteMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');
     $this->websiteMock->expects($this->any())->method('getName')->willReturn('Main Website');
     $this->groupMock->expects($this->atLeastOnce())->method('getWebsiteId')->willReturn('1');
     $this->groupMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');
     $this->groupMock->expects($this->atLeastOnce())->method('getName')->willReturn('Main Website Store');
     $this->storeMock->expects($this->atLeastOnce())->method('getGroupId')->willReturn('1');
     $this->storeMock->expects($this->atLeastOnce())->method('getName')->willReturn('Default Store View');
     $this->storeMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');
     $this->escaperMock->expects($this->atLeastOnce())->method('escapeHtml')->willReturnMap([['Default Store View', null, 'Default Store View'], ['Main Website Store', null, 'Main Website Store'], ['Main Website', null, 'Main Website']]);
     $this->assertEquals($expectedOptions, $this->options->toOptionArray());
 }
コード例 #14
0
ファイル: RuleTest.php プロジェクト: rafaelstz/magento2
 /**
  * @dataProvider dataProviderCallbackValidateProduct
  * @param bool $validate
  *
  * @return void
  */
 public function testCallbackValidateProduct($validate)
 {
     $args['product'] = $this->productModel;
     $args['attributes'] = [];
     $args['idx'] = 0;
     $args['row'] = ['entity_id' => '1', 'entity_type_id' => '4', 'attribute_set_id' => '4', 'type_id' => 'simple', 'sku' => 'Product', 'has_options' => '0', 'required_options' => '0', 'created_at' => '2014-06-25 13:14:30', 'updated_at' => '2014-06-25 14:37:15'];
     $this->storeManager->expects($this->any())->method('getWebsites')->with(false)->will($this->returnValue([$this->websiteModel, $this->websiteModel]));
     $this->websiteModel->expects($this->at(0))->method('getId')->will($this->returnValue('1'));
     $this->websiteModel->expects($this->at(2))->method('getId')->will($this->returnValue('2'));
     $this->websiteModel->expects($this->any())->method('getDefaultStore')->will($this->returnValue($this->storeModel));
     $this->storeModel->expects($this->at(0))->method('getId')->will($this->returnValue('1'));
     $this->storeModel->expects($this->at(1))->method('getId')->will($this->returnValue('2'));
     $this->combineFactory->expects($this->any())->method('create')->will($this->returnValue($this->condition));
     $this->condition->expects($this->any())->method('validate')->will($this->returnValue($validate));
     $this->condition->expects($this->any())->method('setRule')->will($this->returnSelf());
     $this->productModel->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->rule->callbackValidateProduct($args);
     $matchingProducts = $this->rule->getMatchingProductIds();
     foreach ($matchingProducts['1'] as $matchingRules) {
         $this->assertEquals($validate, $matchingRules);
     }
 }
コード例 #15
0
ファイル: Email.php プロジェクト: nja78/magento2
 /**
  * Send customer email
  *
  * @return bool
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function send()
 {
     if ($this->_website === null || $this->_customer === null) {
         return false;
     }
     if ($this->_type == 'price' && count($this->_priceProducts) == 0 || $this->_type == 'stock' && count($this->_stockProducts) == 0) {
         return false;
     }
     if (!$this->_website->getDefaultGroup() || !$this->_website->getDefaultGroup()->getDefaultStore()) {
         return false;
     }
     if ($this->_customer->getStoreId() > 0) {
         $store = $this->_storeManager->getStore($this->_customer->getStoreId());
     } else {
         $store = $this->_website->getDefaultStore();
     }
     $storeId = $store->getId();
     if ($this->_type == 'price' && !$this->_scopeConfig->getValue(self::XML_PATH_EMAIL_PRICE_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId)) {
         return false;
     } elseif ($this->_type == 'stock' && !$this->_scopeConfig->getValue(self::XML_PATH_EMAIL_STOCK_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId)) {
         return false;
     }
     if ($this->_type != 'price' && $this->_type != 'stock') {
         return false;
     }
     $this->_appEmulation->startEnvironmentEmulation($storeId);
     if ($this->_type == 'price') {
         $this->_getPriceBlock()->setStore($store)->reset();
         foreach ($this->_priceProducts as $product) {
             $product->setCustomerGroupId($this->_customer->getGroupId());
             $this->_getPriceBlock()->addProduct($product);
         }
         $block = $this->_getPriceBlock();
         $templateId = $this->_scopeConfig->getValue(self::XML_PATH_EMAIL_PRICE_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
     } else {
         $this->_getStockBlock()->setStore($store)->reset();
         foreach ($this->_stockProducts as $product) {
             $product->setCustomerGroupId($this->_customer->getGroupId());
             $this->_getStockBlock()->addProduct($product);
         }
         $block = $this->_getStockBlock();
         $templateId = $this->_scopeConfig->getValue(self::XML_PATH_EMAIL_STOCK_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
     }
     $alertGrid = $this->_appState->emulateAreaCode(\Magento\Framework\App\Area::AREA_FRONTEND, [$block, 'toHtml']);
     $this->_appEmulation->stopEnvironmentEmulation();
     $transport = $this->_transportBuilder->setTemplateIdentifier($templateId)->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId])->setTemplateVars(['customerName' => $this->_customerHelper->getCustomerName($this->_customer), 'alertGrid' => $alertGrid])->setFrom($this->_scopeConfig->getValue(self::XML_PATH_EMAIL_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId))->addTo($this->_customer->getEmail(), $this->_customerHelper->getCustomerName($this->_customer))->getTransport();
     $transport->sendMessage();
     return true;
 }
コード例 #16
0
ファイル: Db.php プロジェクト: aiesh/magento2
 /**
  *  Unset website by id from app cache
  *
  * @param null|bool|int|string|Website $websiteId
  * @return void
  */
 public function clearWebsiteCache($websiteId = null)
 {
     if (is_null($websiteId)) {
         $websiteId = $this->getStore()->getWebsiteId();
     } elseif ($websiteId instanceof Website) {
         $websiteId = $websiteId->getId();
     } elseif ($websiteId === true) {
         $websiteId = $this->_website->getId();
     }
     if (!empty($this->_websites[$websiteId])) {
         $website = $this->_websites[$websiteId];
         unset($this->_websites[$website->getWebsiteId()]);
         unset($this->_websites[$website->getCode()]);
     }
 }
コード例 #17
0
 /**
  * Test get Value
  */
 public function testGetValue()
 {
     $coreStoreId = 1;
     $coreWebsiteId = 1;
     $productId = 1;
     $customerGroupId = 1;
     $dateTime = time();
     $expectedValue = 55.12;
     $this->coreStoreMock->expects($this->once())->method('getId')->will($this->returnValue($coreStoreId));
     $this->coreStoreMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue($coreWebsiteId));
     $this->dataTimeMock->expects($this->once())->method('scopeTimeStamp')->with($this->equalTo($coreStoreId))->will($this->returnValue($dateTime));
     $this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue($customerGroupId));
     $this->catalogRuleResourceMock->expects($this->once())->method('getRulePrice')->will($this->returnValue($expectedValue));
     $this->saleableItemMock->expects($this->any())->method('getId')->will($this->returnValue($productId));
     $this->assertEquals($expectedValue, $this->object->getValue());
 }
コード例 #18
0
 /**
  * testGetTierPrices
  * testSetTierPrices
  *
  * @dataProvider pricesDataProvider
  */
 public function testTierPrices($priceScope, $expectedWebsiteId)
 {
     // establish the behavior of the mocks
     $this->scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValue($priceScope));
     $this->websiteMock->expects($this->any())->method('getId')->will($this->returnValue($expectedWebsiteId));
     $this->tpFactory->expects($this->any())->method('create')->will($this->returnCallback(function () {
         return $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Product\\TierPrice');
     }));
     // create sample TierPrice objects that would be coming from a REST call
     $tp1 = $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Product\\TierPrice');
     $tp1->setValue(10);
     $tp1->setCustomerGroupId(1);
     $tp1->setQty(11);
     $tp2 = $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Product\\TierPrice');
     $tp2->setValue(20);
     $tp2->setCustomerGroupId(2);
     $tp2->setQty(22);
     $tps = [$tp1, $tp2];
     // force the product to have null tier prices
     $this->product->setData($this::KEY_TIER_PRICE, null);
     $this->assertNull($this->product->getData($this::KEY_TIER_PRICE));
     // set the product with the TierPrice objects
     $this->model->setTierPrices($this->product, $tps);
     // test the data actually set on the product
     $tpArray = $this->product->getData($this::KEY_TIER_PRICE);
     $this->assertNotNull($tpArray);
     $this->assertTrue(is_array($tpArray));
     $this->assertEquals(sizeof($tps), sizeof($tpArray));
     for ($i = 0; $i < sizeof($tps); $i++) {
         $tpData = $tpArray[$i];
         $this->assertEquals($expectedWebsiteId, $tpData['website_id'], 'Website Id does not match');
         $this->assertEquals($tps[$i]->getValue(), $tpData['price'], 'Price/Value does not match');
         $this->assertEquals($tps[$i]->getValue(), $tpData['website_price'], 'WebsitePrice/Value does not match');
         $this->assertEquals($tps[$i]->getCustomerGroupId(), $tpData['cust_group'], 'Customer group Id does not match');
         $this->assertEquals($tps[$i]->getQty(), $tpData['price_qty'], 'Qty does not match');
     }
     // test with the data retrieved as a REST object
     $tpRests = $this->model->getTierPrices($this->product);
     $this->assertNotNull($tpRests);
     $this->assertTrue(is_array($tpRests));
     $this->assertEquals(sizeof($tps), sizeof($tpRests));
     for ($i = 0; $i < sizeof($tps); $i++) {
         $this->assertEquals($tps[$i]->getValue(), $tpRests[$i]->getValue(), 'REST: Price/Value does not match');
         $this->assertEquals($tps[$i]->getCustomerGroupId(), $tpRests[$i]->getCustomerGroupId(), 'REST: Customer group Id does not match');
         $this->assertEquals($tps[$i]->getQty(), $tpRests[$i]->getQty(), 'REST: Qty does not match');
     }
 }
コード例 #19
0
 /**
  * Store name datafield.
  *
  * @param \Magento\Store\Model\Website $website
  *
  * @return mixed|string
  */
 public function getMappedStoreName(\Magento\Store\Model\Website $website)
 {
     $mapped = $website->getConfig(\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_STORENAME);
     $storeName = $mapped ? $mapped : '';
     return $storeName;
 }
コード例 #20
0
ファイル: WebsiteTest.php プロジェクト: aiesh/magento2
 public function testCollection()
 {
     $collection = $this->_model->getCollection()->joinGroupAndStore()->addIdFilter(1);
     $this->assertEquals(1, count($collection->getItems()));
 }
コード例 #21
0
ファイル: Store.php プロジェクト: mrbadao/magento-ce
 /**
  * Set relation to the website
  *
  * @param Website $website
  * @return void
  */
 public function setWebsite(Website $website)
 {
     $this->setWebsiteId($website->getId());
 }
コード例 #22
0
 /**
  * Get reviews for export.
  *
  * @param \Magento\Store\Model\Website $website
  * @param int $limit
  *
  * @return mixed
  */
 public function _getReviewsToExport(\Magento\Store\Model\Website $website, $limit = 100)
 {
     return $this->reviewCollection->create()->addFieldToFilter('review_imported', ['null' => 'true'])->addFieldToFilter('store_id', ['in' => $website->getStoreIds()])->setPageSize($limit);
 }
コード例 #23
0
ファイル: Cookie.php プロジェクト: pavelnovitsky/magento2
 /**
  * Return serialized list of accepted save cookie website
  *
  * @return string
  */
 public function getAcceptedSaveCookiesWebsiteIds()
 {
     $acceptedSaveCookiesWebsites = $this->_getAcceptedSaveCookiesWebsites();
     $acceptedSaveCookiesWebsites[$this->_website->getId()] = 1;
     return json_encode($acceptedSaveCookiesWebsites);
 }
コード例 #24
0
ファイル: WebsiteTest.php プロジェクト: Doability/magento2dev
 public function testGetScopeTypeName()
 {
     $this->assertEquals('Website', $this->model->getScopeTypeName());
 }
コード例 #25
0
ファイル: Switcher.php プロジェクト: koliaGI/magento2
 /**
  * @param \Magento\Store\Model\Website $website
  * @return bool
  */
 public function isWebsiteSelected(\Magento\Store\Model\Website $website)
 {
     return $this->getWebsiteId() === $website->getId() && $this->getStoreId() === null;
 }
コード例 #26
0
ファイル: Websites.php プロジェクト: pradeep-wagento/magento2
 /**
  * @param Website $website
  * @return Group[]
  */
 public function getGroupCollection(Website $website)
 {
     return $website->getGroups();
 }
コード例 #27
0
 /**
  * {@inheritdoc}
  */
 public function offsetGet($offset)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'offsetGet');
     if (!$pluginInfo) {
         return parent::offsetGet($offset);
     } else {
         return $this->___callPlugins('offsetGet', func_get_args(), $pluginInfo);
     }
 }
コード例 #28
0
 /**
  * Set Website scope
  *
  * @param Website|int $website
  * @return $this
  */
 public function setWebsite($website)
 {
     $this->_website = $this->_storeManager->getWebsite($website);
     $this->addBindParam('scope_website_id', $this->_website->getId());
     return $this;
 }
コード例 #29
0
ファイル: Status.php プロジェクト: pradeep-wagento/magento2
 /**
  * Add stock status to prepare index select
  *
  * @param \Magento\Framework\DB\Select $select
  * @param \Magento\Store\Model\Website $website
  * @return Status
  */
 public function addStockStatusToSelect(\Magento\Framework\DB\Select $select, \Magento\Store\Model\Website $website)
 {
     $websiteId = $website->getId();
     $select->joinLeft(['stock_status' => $this->getMainTable()], 'e.entity_id = stock_status.product_id AND stock_status.website_id=' . $websiteId, ['salable' => 'stock_status.stock_status']);
     return $this;
 }
コード例 #30
0
 /**
  * Get all websites value with currency code
  *
  * @return string
  */
 public function getAllWebsitesValue()
 {
     return AdvancedPricing::VALUE_ALL_WEBSITES . ' [' . $this->websiteModel->getBaseCurrency()->getCurrencyCode() . ']';
 }