コード例 #1
1
 public function testGetId()
 {
     $storeId = 2;
     $websiteId = 55;
     $this->storeSwitcher->expects($this->once())->method('isInitialized')->willReturn(true);
     $store = $this->getMock('Magento\\Store\\Api\\Data\\StoreInterface');
     $store->expects($this->once())->method('getWebsiteId')->willReturn($websiteId);
     $this->storeSwitcher->expects($this->once())->method('getStoreId')->willReturn($storeId);
     $this->storeRepository->expects($this->once())->method('getById')->with($storeId)->willReturn($store);
     $this->assertSame($websiteId, $this->geoWebsite->getId());
     $this->assertSame($websiteId, $this->geoWebsite->getId());
 }
コード例 #2
1
 /**
  * @return bool|int
  */
 public function getId()
 {
     if (null === $this->defaultWebsiteId && $this->storeSwitcher->isInitialized()) {
         try {
             $storeId = $this->storeSwitcher->getStoreId();
             if ($storeId) {
                 $store = $this->storeRepository->getById($storeId);
                 $this->defaultWebsiteId = $store->getWebsiteId();
             } else {
                 $this->defaultWebsiteId = false;
             }
         } catch (\Exception $e) {
             $this->defaultWebsiteId = false;
         }
     }
     return $this->defaultWebsiteId ?: false;
 }
コード例 #3
0
ファイル: SwitchAction.php プロジェクト: nblair/magescotch
    /**
     * @return void
     */
    public function executeInternal()
    {
        $storeCode = $this->_request->getParam(
            StoreResolver::PARAM_NAME,
            $this->storeCookieManager->getStoreCodeFromCookie()
        );

        try {
            $store = $this->storeRepository->getActiveStoreByCode($storeCode);
        } catch (StoreIsInactiveException $e) {
            $error = __('Requested store is inactive');
        } catch (NoSuchEntityException $e) {
            $error = __('Requested store is not found');
        }

        if (isset($error)) {
            $this->messageManager->addError($error);
            $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl());
            return;
        }

        $defaultStoreView = $this->storeManager->getDefaultStoreView();
        if ($defaultStoreView->getId() == $store->getId()) {
            $this->storeCookieManager->deleteStoreCookie($store);
        } else {
            $this->httpContext->setValue(Store::ENTITY, $store->getCode(), $defaultStoreView->getCode());
            $this->storeCookieManager->setStoreCookie($store);
        }

        $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl());
    }
コード例 #4
0
 /**
  * @param int|bool $storeId
  * @return \Magento\Store\Model\Website
  */
 protected function getWebsite($storeId)
 {
     if ($storeId) {
         $websiteId = $this->storeRepository->getById($storeId)->getWebsiteId();
         $website = $this->websiteRepository->getById($websiteId);
     } else {
         $website = $this->websiteRepository->getDefault();
     }
     return $website;
 }
コード例 #5
0
ファイル: Group.php プロジェクト: pradeep-wagento/magento2
 /**
  * {@inheritdoc}
  */
 public function getAllowedStoreIds($scopeCode)
 {
     $stores = [];
     foreach ($this->storeRepository->getList() as $store) {
         if ($store->isActive() && (int) $store->getGroupId() === $scopeCode) {
             $stores[] = $store->getId();
         }
     }
     return $stores;
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function getAllowedStoreIds($scopeCode)
 {
     $stores = [];
     $website = $scopeCode ? $this->websiteRepository->get($scopeCode) : $this->websiteRepository->getDefault();
     foreach ($this->storeRepository->getList() as $store) {
         if ($store->isActive() && $store->getWebsiteId() == $website->getId()) {
             $stores[] = $store->getId();
         }
     }
     return $stores;
 }
 /**
  * Get data
  *
  * @return array
  */
 public function getData()
 {
     if (!$this->getCollection()->isLoaded()) {
         $this->getCollection()->addAttributeToFilter('type_id', $this->config->getComposableTypes());
         if ($storeId = $this->request->getParam('current_store_id')) {
             /** @var StoreInterface $store */
             $store = $this->storeRepository->getById($storeId);
             $this->getCollection()->setStore($store);
         }
         $this->getCollection()->load();
     }
     $items = $this->getCollection()->toArray();
     return ['totalRecords' => $this->getCollection()->getSize(), 'items' => array_values($items)];
 }
コード例 #8
0
 /**
  * Delete cookie "store" if the store (a value in the cookie) does not exist or is inactive
  *
  * @param \Magento\Framework\App\FrontController $subject
  * @param \Magento\Framework\App\RequestInterface $request
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeDispatch(\Magento\Framework\App\FrontController $subject, \Magento\Framework\App\RequestInterface $request)
 {
     $storeCodeFromCookie = $this->storeCookieManager->getStoreCodeFromCookie();
     if ($storeCodeFromCookie) {
         try {
             $this->storeRepository->getActiveStoreByCode($storeCodeFromCookie);
         } catch (StoreIsInactiveException $e) {
             $this->storeCookieManager->deleteStoreCookie($this->storeManager->getDefaultStoreView());
         } catch (NoSuchEntityException $e) {
             $this->storeCookieManager->deleteStoreCookie($this->storeManager->getDefaultStoreView());
         } catch (InvalidArgumentException $e) {
             $this->storeCookieManager->deleteStoreCookie($this->storeManager->getDefaultStoreView());
         }
     }
 }
コード例 #9
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);
 }
コード例 #10
0
ファイル: Websites.php プロジェクト: rafaelstz/magento2
 /**
  * Prepares websites list with groups and stores as array
  *
  * @return array
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function getWebsitesList()
 {
     if (!empty($this->websitesList)) {
         return $this->websitesList;
     }
     $this->websitesList = [];
     $groupList = $this->groupRepository->getList();
     $storesList = $this->storeRepository->getList();
     foreach ($this->websiteRepository->getList() as $website) {
         $websiteId = $website->getId();
         if (!$websiteId) {
             continue;
         }
         $websiteRow = ['id' => $websiteId, 'name' => $website->getName(), 'storesCount' => 0, 'groups' => []];
         foreach ($groupList as $group) {
             $groupId = $group->getId();
             if (!$groupId || $group->getWebsiteId() != $websiteId) {
                 continue;
             }
             $groupRow = ['id' => $groupId, 'name' => $group->getName(), 'stores' => []];
             foreach ($storesList as $store) {
                 $storeId = $store->getId();
                 if (!$storeId || $store->getStoreGroupId() != $groupId) {
                     continue;
                 }
                 $websiteRow['storesCount']++;
                 $groupRow['stores'][] = ['id' => $storeId, 'name' => $store->getName()];
             }
             $websiteRow['groups'][] = $groupRow;
         }
         $this->websitesList[] = $websiteRow;
     }
     return $this->websitesList;
 }
コード例 #11
0
 public function testAfterGetDefaultStore()
 {
     $storeId = 1;
     $websiteStoreIds = [1, 2, 3];
     $geoStoreId = 2;
     $this->generalConfig->expects($this->once())->method('isAvailable')->willReturn(true);
     $this->storeSwitcher->expects($this->once())->method('isInitialized')->willReturn(true);
     $this->storeSwitcher->expects($this->once())->method('getStoreId')->willReturn($geoStoreId);
     $website = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->getMock();
     $website->expects($this->once())->method('getStoreIds')->willReturn($websiteStoreIds);
     $store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $store->expects($this->once())->method('getId')->willReturn($storeId);
     $geoStore = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $this->storeRepository->expects($this->once())->method('getById')->willReturn($geoStore);
     $this->assertSame($geoStore, $this->geoWebsite->afterGetDefaultStore($website, $store));
 }
コード例 #12
0
 /**
  * {@inheritdoc}
  */
 public function reinitStores()
 {
     $this->currentStoreId = null;
     $this->storeRepository->clean();
     $this->websiteRepository->clean();
     $this->groupRepository->clean();
     $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [StoreResolver::CACHE_TAG]);
 }
コード例 #13
0
 /**
  * Retrieve active store by code
  *
  * @param int $id
  * @return \Magento\Store\Api\Data\StoreInterface
  * @throws NoSuchEntityException
  */
 protected function getDefaultStoreById($id)
 {
     try {
         $store = $this->storeRepository->getActiveStoreById($id);
     } catch (StoreIsInactiveException $e) {
         throw new NoSuchEntityException(__('Default store is inactive'));
     }
     return $store;
 }
コード例 #14
0
ファイル: StoreCookieTest.php プロジェクト: tingyeeh/magento2
 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));
 }
コード例 #15
0
ファイル: StoreCookieTest.php プロジェクト: vv-team/foodo
 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);
 }
コード例 #16
0
 /**
  * Retrieve store
  *
  * @return StoreInterface|null
  */
 protected function getStore()
 {
     if (null !== $this->store) {
         return $this->store;
     }
     if (!($storeId = $this->request->getParam('current_store_id'))) {
         return null;
     }
     return $this->store = $this->storeRepository->getById($storeId);
 }
コード例 #17
0
 /**
  * Customize options
  *
  * @param array $meta
  * @return array
  */
 private function customizeOptions($meta)
 {
     $sortOrder = 1;
     foreach ($this->storeRepository->getList() as $store) {
         $storeId = $store->getId();
         $meta['attribute_options_select_container']['children']['attribute_options_select']['children']['record']['children']['value_option_' . $storeId] = $this->arrayManager->set('arguments/data/config', [], ['dataType' => 'text', 'formElement' => 'input', 'component' => 'Magento_Catalog/js/form/element/input', 'template' => 'Magento_Catalog/form/element/input', 'prefixName' => 'option.value', 'prefixElementName' => 'option_', 'suffixName' => (string) $storeId, 'label' => $store->getName(), 'sortOrder' => $sortOrder, 'componentType' => Field::NAME]);
         $meta['attribute_options_multiselect_container']['children']['attribute_options_multiselect']['children']['record']['children']['value_option_' . $storeId] = $this->arrayManager->set('arguments/data/config', [], ['dataType' => 'text', 'formElement' => 'input', 'component' => 'Magento_Catalog/js/form/element/input', 'template' => 'Magento_Catalog/form/element/input', 'prefixName' => 'option.value', 'prefixElementName' => 'option_', 'suffixName' => (string) $storeId, 'label' => $store->getName(), 'sortOrder' => $sortOrder, 'componentType' => Field::NAME]);
         ++$sortOrder;
     }
     $meta['attribute_options_select_container']['children']['attribute_options_select']['children']['record']['children']['action_delete'] = $this->arrayManager->set('arguments/data/config', [], ['componentType' => 'actionDelete', 'dataType' => 'text', 'fit' => true, 'sortOrder' => $sortOrder, 'component' => 'Magento_Catalog/js/form/element/action-delete', 'elementTmpl' => 'Magento_Catalog/form/element/action-delete', 'template' => 'Magento_Catalog/form/element/action-delete', 'prefixName' => 'option.delete', 'prefixElementName' => 'option_']);
     $meta['attribute_options_multiselect_container']['children']['attribute_options_multiselect']['children']['record']['children']['action_delete'] = $this->arrayManager->set('arguments/data/config', [], ['componentType' => 'actionDelete', 'dataType' => 'text', 'fit' => true, 'sortOrder' => $sortOrder, 'component' => 'Magento_Catalog/js/form/element/action-delete', 'elementTmpl' => 'Magento_Catalog/form/element/action-delete', 'template' => 'Magento_Catalog/form/element/action-delete', 'prefixName' => 'option.delete', 'prefixElementName' => 'option_']);
     return $meta;
 }
コード例 #18
0
 public function testUpdateStoreIdNotFoundCountryStore()
 {
     $countryCode = 'UA';
     $storeId = 2;
     $websiteStoreCodes = ['us', 'uk'];
     $websiteId = 11;
     $this->generalConfig->expects($this->once())->method('isMappingSore')->willReturn(true);
     $store = $this->getMockBuilder('Magento\\Store\\Api\\Data\\StoreInterface')->disableOriginalConstructor()->getMock();
     $store->expects($this->once())->method('getWebsiteId')->willReturn($websiteId);
     $this->storeRepository->expects($this->once())->method('getById')->willReturn($store);
     $this->storeRepository->expects($this->never())->method('get');
     $website = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->getMock();
     $website->expects($this->once())->method('getStoreCodes')->willReturn($websiteStoreCodes);
     $this->websiteRepository->expects($this->once())->method('getById')->with($websiteId)->willReturn($website);
     $this->websiteRepository->expects($this->never())->method('getDefault');
     $this->assertEquals($storeId, $this->countryStoreMapping->updateStoreId($storeId, $countryCode));
 }
コード例 #19
0
 public function testExecuteSuccessWithUseStoreInUrl()
 {
     $currentActiveStoreCode = 'sv1';
     $storeToSwitchToCode = 'sv2';
     $defaultStoreViewCode = 'default';
     $originalRedirectUrl = "magento.com/{$currentActiveStoreCode}/test-page/test-sub-page";
     $expectedRedirectUrl = "magento.com/{$storeToSwitchToCode}/test-page/test-sub-page";
     $currentActiveStoreMock = $this->getMockBuilder('Magento\\Store\\Api\\Data\\StoreInterface')->disableOriginalConstructor()->setMethods(['isUseStoreInUrl', 'getBaseUrl'])->getMockForAbstractClass();
     $defaultStoreViewMock = $this->getMockBuilder('Magento\\Store\\Api\\Data\\StoreInterface')->getMock();
     $storeToSwitchToMock = $this->getMockBuilder('Magento\\Store\\Api\\Data\\StoreInterface')->disableOriginalConstructor()->setMethods(['isUseStoreInUrl', 'getBaseUrl'])->getMockForAbstractClass();
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($currentActiveStoreMock);
     $this->requestMock->expects($this->once())->method('getParam')->willReturn($storeToSwitchToCode);
     $this->storeRepositoryMock->expects($this->once())->method('getActiveStoreByCode')->willReturn($storeToSwitchToMock);
     $this->storeManagerMock->expects($this->once())->method('getDefaultStoreView')->willReturn($defaultStoreViewMock);
     $defaultStoreViewMock->expects($this->once())->method('getId')->willReturn($defaultStoreViewCode);
     $storeToSwitchToMock->expects($this->once())->method('getId')->willReturn($storeToSwitchToCode);
     $storeToSwitchToMock->expects($this->once())->method('isUseStoreInUrl')->willReturn(true);
     $this->redirectMock->expects($this->any())->method('getRedirectUrl')->willReturn($originalRedirectUrl);
     $currentActiveStoreMock->expects($this->any())->method('getBaseUrl')->willReturn("magento.com/{$currentActiveStoreCode}");
     $storeToSwitchToMock->expects($this->once())->method('getBaseUrl')->willReturn("magento.com/{$storeToSwitchToCode}");
     $this->responseMock->expects($this->once())->method('setRedirect')->with($expectedRedirectUrl);
     $this->model->execute();
 }
コード例 #20
0
ファイル: Store.php プロジェクト: kidaa30/magento2-platformsh
 /**
  * {@inheritdoc}
  */
 public function getDefaultStoreId($scopeCode)
 {
     return $this->storeRepository->get($scopeCode)->getId();
 }
コード例 #21
0
 /**
  * Creates and returns a populated getTaxRequest for a invoice
  *
  * @param \Magento\Sales\Api\Data\InvoiceInterface|\Magento\Sales\Api\Data\CreditmemoInterface $object
  * @return GetTaxRequest
  */
 public function getGetTaxRequestForSalesObject($object)
 {
     $order = $this->orderRepository->get($object->getOrderId());
     $lines = [];
     $items = $object->getItems();
     $this->taxClassHelper->populateCorrectTaxClasses($items, $object->getStoreId());
     /** @var \Magento\Tax\Api\Data\QuoteDetailsItemInterface $item */
     foreach ($items as $item) {
         $line = $this->interactionLine->getLine($item);
         if ($line) {
             $lines[] = $line;
         }
     }
     $objectIsCreditMemo = $object instanceof \Magento\Sales\Api\Data\CreditmemoInterface;
     $credit = $objectIsCreditMemo;
     $line = $this->interactionLine->getShippingLine($object, $credit);
     if ($line) {
         $lines[] = $line;
     }
     $line = $this->interactionLine->getGiftWrapItemsLine($object, $credit);
     if ($line) {
         $lines[] = $line;
     }
     $line = $this->interactionLine->getGiftWrapOrderLine($object, $credit);
     if ($line) {
         $lines[] = $line;
     }
     $line = $this->interactionLine->getGiftWrapCardLine($object, $credit);
     if ($line) {
         $lines[] = $line;
     }
     if ($objectIsCreditMemo) {
         $line = $this->interactionLine->getPositiveAdjustmentLine($object);
         if ($line) {
             $lines[] = $line;
         }
         $line = $this->interactionLine->getNegativeAdjustmentLine($object);
         if ($line) {
             $lines[] = $line;
         }
     }
     /** @var \Magento\Sales\Api\Data\OrderAddressInterface $address */
     if (!$order->getIsVirtual()) {
         $address = $order->getShippingAddress();
     } else {
         $address = $order->getBillingAddress();
     }
     $avaTaxAddress = $this->address->getAddress($address);
     $store = $this->storeRepository->getById($object->getStoreId());
     $currentDate = $this->getFormattedDate($store, $object->getCreatedAt());
     $taxOverride = null;
     if ($object instanceof \Magento\Sales\Api\Data\InvoiceInterface) {
         $docType = DocumentType::$SalesInvoice;
         if ($this->areTimesDifferentDays($order->getCreatedAt(), $object->getCreatedAt(), $object->getStoreId())) {
             $taxCalculationDate = $this->getFormattedDate($store, $order->getCreatedAt());
             // Set the tax date for calculation
             $taxOverride = $this->taxOverrideFactory->create();
             $taxOverride->setTaxDate($taxCalculationDate);
             $taxOverride->setTaxOverrideType(\AvaTax\TaxOverrideType::$TaxDate);
             $taxOverride->setTaxAmount(0.0);
             $taxOverride->setReason(self::AVATAX_INVOICE_OVERRIDE_REASON);
         }
     } else {
         $docType = DocumentType::$ReturnInvoice;
         $invoice = $this->getInvoice($object->getInvoiceId());
         // If a Creditmemo was generated for an invoice, use the created_at value from the invoice
         if ($invoice) {
             $taxCalculationDate = $this->getFormattedDate($store, $invoice->getCreatedAt());
         } else {
             $taxCalculationDate = $this->getFormattedDate($store, $order->getCreatedAt());
         }
         // Set the tax date for calculation
         $taxOverride = $this->taxOverrideFactory->create();
         $taxOverride->setTaxDate($taxCalculationDate);
         $taxOverride->setTaxOverrideType(\AvaTax\TaxOverrideType::$TaxDate);
         $taxOverride->setTaxAmount(0.0);
         $taxOverride->setReason(self::AVATAX_CREDITMEMO_OVERRIDE_REASON);
     }
     $customer = $this->getCustomerById($order->getCustomerId());
     $customerUsageType = $customer ? $this->taxClassHelper->getAvataxTaxCodeForCustomer($customer) : null;
     $data = ['StoreId' => $store->getId(), 'Commit' => $this->config->getCommitSubmittedTransactions($store), 'TaxOverride' => $taxOverride, 'CurrencyCode' => $order->getOrderCurrencyCode(), 'CustomerCode' => $this->getCustomerCode($order), 'CustomerUsageType' => $customerUsageType, 'DestinationAddress' => $avaTaxAddress, 'DocCode' => $object->getIncrementId() . '123-' . rand(10000000, 90000000000), 'DocDate' => $currentDate, 'DocType' => $docType, 'ExchangeRate' => $this->getExchangeRate($store, $order->getBaseCurrencyCode(), $order->getOrderCurrencyCode()), 'ExchangeRateEffDate' => $currentDate, 'Lines' => $lines, 'DetailLevel' => DetailLevel::$Document, 'PaymentDate' => $currentDate, 'PurchaseOrderNo' => $object->getIncrementId()];
     $data = array_merge($this->retrieveGetTaxRequestFields($store, $address, $object), $data);
     try {
         $data = $this->metaDataObject->validateData($data);
     } catch (ValidationException $e) {
         $this->avaTaxLogger->error('Error validating data: ' . $e->getMessage(), ['data' => var_export($data, true)]);
     }
     /** @var $getTaxRequest GetTaxRequest */
     $getTaxRequest = $this->getTaxRequestFactory->create();
     $this->populateGetTaxRequest($data, $getTaxRequest);
     return $getTaxRequest;
 }
コード例 #22
0
 /**
  * @return \Magento\Store\Model\Store
  */
 protected function loadSource()
 {
     return $this->storeRespository->getById($this->getStoreId());
 }
コード例 #23
0
ファイル: Store.php プロジェクト: owebia/module-shipping-core
 /**
  * @return \Magento\Store\Model\Store
  */
 protected function loadSource()
 {
     return $this->storeRespository->getById($this->request->getData('store_id'));
 }
コード例 #24
0
 /**
  * @dataProvider getStoresDataProvider
  */
 public function testGetStores($storesList, $withDefault, $codeKey, $expectedStores)
 {
     $this->storeRepositoryMock->expects($this->any())->method('getList')->willReturn($storesList);
     $this->assertEquals($expectedStores, $this->model->getStores($withDefault, $codeKey));
 }
コード例 #25
-1
 /**
  * @param \Magento\Store\Model\Group $subject
  * @param \Magento\Store\Model\Store $store
  * @return \Magento\Store\Model\Store
  */
 public function afterGetDefaultStore(Group $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;
 }