Skip to content

Commit f6642c8

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into 2.2-develop-pr92
2 parents e44aae2 + 5358ec9 commit f6642c8

File tree

25 files changed

+597
-72
lines changed

25 files changed

+597
-72
lines changed

app/code/Magento/Braintree/Controller/Paypal/PlaceOrder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function execute()
7474
$this->logger->critical($e);
7575
$this->messageManager->addExceptionMessage(
7676
$e,
77-
'The order #' . $quote->getReservedOrderId() . ' cannot be processed.'
77+
__('The order #%1 cannot be processed.', $quote->getReservedOrderId())
7878
);
7979
}
8080

app/code/Magento/Catalog/Api/Data/CategoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function setParentId($parentId);
4343
/**
4444
* Get category name
4545
*
46-
* @return string
46+
* @return string|null
4747
*/
4848
public function getName();
4949

app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,9 @@ protected function _getItemsData()
111111
$from = '';
112112
}
113113
if ($to == '*') {
114-
$to = '';
114+
$to = null;
115115
}
116-
$label = $this->renderRangeLabel(
117-
empty($from) ? 0 : $from,
118-
empty($to) ? 0 : $to
119-
);
116+
$label = $this->renderRangeLabel(empty($from) ? 0 : $from, $to);
120117
$value = $from . '-' . $to;
121118

122119
$data[] = [
@@ -141,7 +138,7 @@ protected function _getItemsData()
141138
protected function renderRangeLabel($fromPrice, $toPrice)
142139
{
143140
$formattedFromPrice = $this->priceCurrency->format($fromPrice);
144-
if ($toPrice === '') {
141+
if ($toPrice === null) {
145142
return __('%1 and above', $formattedFromPrice);
146143
} else {
147144
if ($fromPrice != $toPrice) {

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\Customer\Model\Data\Customer;
2020
use Magento\Customer\Model\Metadata\Validator;
2121
use Magento\Customer\Model\ResourceModel\Visitor\CollectionFactory;
22+
use Magento\Directory\Model\AllowedCountries;
2223
use Magento\Eav\Model\Validator\Attribute\Backend;
2324
use Magento\Framework\Api\ExtensibleDataObjectConverter;
2425
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -339,6 +340,11 @@ class AccountManagement implements AccountManagementInterface
339340
*/
340341
private $addressRegistry;
341342

343+
/**
344+
* @var AllowedCountries
345+
*/
346+
private $allowedCountriesReader;
347+
342348
/**
343349
* @param CustomerFactory $customerFactory
344350
* @param ManagerInterface $eventManager
@@ -371,8 +377,10 @@ class AccountManagement implements AccountManagementInterface
371377
* @param CollectionFactory|null $visitorCollectionFactory
372378
* @param SearchCriteriaBuilder|null $searchCriteriaBuilder
373379
* @param AddressRegistry|null $addressRegistry
380+
* @param AllowedCountries|null $allowedCountriesReader
374381
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
375382
* @SuppressWarnings(PHPMD.NPathComplexity)
383+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
376384
*/
377385
public function __construct(
378386
CustomerFactory $customerFactory,
@@ -405,7 +413,8 @@ public function __construct(
405413
SaveHandlerInterface $saveHandler = null,
406414
CollectionFactory $visitorCollectionFactory = null,
407415
SearchCriteriaBuilder $searchCriteriaBuilder = null,
408-
AddressRegistry $addressRegistry = null
416+
AddressRegistry $addressRegistry = null,
417+
AllowedCountries $allowedCountriesReader = null
409418
) {
410419
$this->customerFactory = $customerFactory;
411420
$this->eventManager = $eventManager;
@@ -445,6 +454,8 @@ public function __construct(
445454
?: ObjectManager::getInstance()->get(SearchCriteriaBuilder::class);
446455
$this->addressRegistry = $addressRegistry
447456
?: ObjectManager::getInstance()->get(AddressRegistry::class);
457+
$this->allowedCountriesReader = $allowedCountriesReader
458+
?: ObjectManager::getInstance()->get(AllowedCountries::class);
448459
}
449460

450461
/**
@@ -882,6 +893,9 @@ public function createAccountWithPasswordHash(
882893
}
883894
try {
884895
foreach ($customerAddresses as $address) {
896+
if (!$this->isAddressAllowedForWebsite($address, $customer->getStoreId())) {
897+
continue;
898+
}
885899
if ($address->getId()) {
886900
$newAddress = clone $address;
887901
$newAddress->setId(null);
@@ -1572,4 +1586,18 @@ private function setIgnoreValidationFlag(Customer $customer)
15721586
{
15731587
$customer->setData('ignore_validation_flag', true);
15741588
}
1589+
1590+
/**
1591+
* Check is address allowed for store
1592+
*
1593+
* @param AddressInterface $address
1594+
* @param int|null $storeId
1595+
* @return bool
1596+
*/
1597+
private function isAddressAllowedForWebsite(AddressInterface $address, $storeId): bool
1598+
{
1599+
$allowedCountries = $this->allowedCountriesReader->getAllowedCountries(ScopeInterface::SCOPE_STORE, $storeId);
1600+
1601+
return in_array($address->getCountryId(), $allowedCountries);
1602+
}
15751603
}

app/code/Magento/Dhl/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<field id="account" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
3232
<label>Account Number</label>
3333
</field>
34-
<field id="content_type" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
34+
<field id="content_type" translate="label comment" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
3535
<label>Content Type (Non Domestic)</label>
3636
<comment>Whether to use Documents or NonDocuments service for non domestic shipments. (Shipments within the EU are classed as domestic)</comment>
3737
<source_model>Magento\Dhl\Model\Source\Contenttype</source_model>

app/code/Magento/Dhl/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Title,Title
6161
Password,Password
6262
"Account Number","Account Number"
6363
"Content Type","Content Type"
64+
"Whether to use Documents or NonDocuments service for non domestic shipments. (Shipments within the EU are classed as domestic)","Whether to use Documents or NonDocuments service for non domestic shipments. (Shipments within the EU are classed as domestic)"
6465
"Calculate Handling Fee","Calculate Handling Fee"
6566
"Handling Applied","Handling Applied"
6667
"""Per Order"" allows a single handling fee for the entire order. ""Per Package"" allows an individual handling fee for each package.","""Per Order"" allows a single handling fee for the entire order. ""Per Package"" allows an individual handling fee for each package."

app/code/Magento/Quote/Model/Quote.php

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77

88
use Magento\Customer\Api\Data\CustomerInterface;
99
use Magento\Customer\Api\Data\GroupInterface;
10+
use Magento\Directory\Model\AllowedCountries;
1011
use Magento\Framework\Api\AttributeValueFactory;
1112
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
1213
use Magento\Framework\Model\AbstractExtensibleModel;
1314
use Magento\Quote\Api\Data\PaymentInterface;
1415
use Magento\Quote\Model\Quote\Address;
1516
use Magento\Quote\Model\Quote\Address\Total as AddressTotal;
1617
use Magento\Sales\Model\Status;
18+
use Magento\Store\Model\ScopeInterface;
1719
use Magento\Framework\App\ObjectManager;
1820
use Magento\Sales\Model\OrderIncrementIdChecker;
1921

@@ -360,6 +362,11 @@ class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\C
360362
*/
361363
private $orderIncrementIdChecker;
362364

365+
/**
366+
* @var AllowedCountries
367+
*/
368+
private $allowedCountriesReader;
369+
363370
/**
364371
* @param \Magento\Framework\Model\Context $context
365372
* @param \Magento\Framework\Registry $registry
@@ -402,6 +409,7 @@ class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\C
402409
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
403410
* @param array $data
404411
* @param OrderIncrementIdChecker|null $orderIncrementIdChecker
412+
* @param AllowedCountries|null $allowedCountriesReader
405413
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
406414
*/
407415
public function __construct(
@@ -445,7 +453,8 @@ public function __construct(
445453
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
446454
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
447455
array $data = [],
448-
OrderIncrementIdChecker $orderIncrementIdChecker = null
456+
OrderIncrementIdChecker $orderIncrementIdChecker = null,
457+
AllowedCountries $allowedCountriesReader = null
449458
) {
450459
$this->quoteValidator = $quoteValidator;
451460
$this->_catalogProduct = $catalogProduct;
@@ -482,6 +491,8 @@ public function __construct(
482491
$this->shippingAssignmentFactory = $shippingAssignmentFactory;
483492
$this->orderIncrementIdChecker = $orderIncrementIdChecker ?: ObjectManager::getInstance()
484493
->get(OrderIncrementIdChecker::class);
494+
$this->allowedCountriesReader = $allowedCountriesReader
495+
?: ObjectManager::getInstance()->get(AllowedCountries::class);
485496
parent::__construct(
486497
$context,
487498
$registry,
@@ -941,7 +952,7 @@ public function assignCustomerWithAddressChange(
941952
/** @var \Magento\Quote\Model\Quote\Address $billingAddress */
942953
$billingAddress = $this->_quoteAddressFactory->create();
943954
$billingAddress->importCustomerAddressData($defaultBillingAddress);
944-
$this->setBillingAddress($billingAddress);
955+
$this->assignAddress($billingAddress);
945956
}
946957
}
947958

@@ -959,7 +970,7 @@ public function assignCustomerWithAddressChange(
959970
$shippingAddress = $this->_quoteAddressFactory->create();
960971
}
961972
}
962-
$this->setShippingAddress($shippingAddress);
973+
$this->assignAddress($shippingAddress, false);
963974
}
964975

965976
return $this;
@@ -2570,4 +2581,34 @@ public function setExtensionAttributes(\Magento\Quote\Api\Data\CartExtensionInte
25702581
{
25712582
return $this->_setExtensionAttributes($extensionAttributes);
25722583
}
2584+
2585+
/**
2586+
* Check is address allowed for store
2587+
*
2588+
* @param Address $address
2589+
* @param int|null $storeId
2590+
* @return bool
2591+
*/
2592+
private function isAddressAllowedForWebsite(Address $address, $storeId): bool
2593+
{
2594+
$allowedCountries = $this->allowedCountriesReader->getAllowedCountries(ScopeInterface::SCOPE_STORE, $storeId);
2595+
2596+
return in_array($address->getCountryId(), $allowedCountries);
2597+
}
2598+
2599+
/**
2600+
* Assign address to quote
2601+
*
2602+
* @param Address $address
2603+
* @param bool $isBillingAddress
2604+
* @return void
2605+
*/
2606+
private function assignAddress(Address $address, bool $isBillingAddress = true)
2607+
{
2608+
if ($this->isAddressAllowedForWebsite($address, $this->getStoreId())) {
2609+
$isBillingAddress
2610+
? $this->setBillingAddress($address)
2611+
: $this->setShippingAddress($address);
2612+
}
2613+
}
25732614
}

app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ public function mapItems(
350350
$useBaseCurrency
351351
) {
352352
$items = $shippingAssignment->getItems();
353-
if (!count($items)) {
353+
if (empty($items)) {
354354
return [];
355355
}
356356

@@ -475,7 +475,7 @@ protected function prepareQuoteDetails(ShippingAssignmentInterface $shippingAssi
475475
{
476476
$items = $shippingAssignment->getItems();
477477
$address = $shippingAssignment->getShipping()->getAddress();
478-
if (!count($items)) {
478+
if (empty($items)) {
479479
return $this->quoteDetailsDataObjectFactory->create();
480480
}
481481

@@ -685,6 +685,9 @@ public function updateItemTaxInfo($quoteItem, $itemTaxDetails, $baseItemTaxDetai
685685
{
686686
//The price should be base price
687687
$quoteItem->setPrice($baseItemTaxDetails->getPrice());
688+
if ($quoteItem->getCustomPrice() && $this->taxHelper->applyTaxOnCustomPrice()) {
689+
$quoteItem->setCustomPrice($baseItemTaxDetails->getPrice());
690+
}
688691
$quoteItem->setConvertedPrice($itemTaxDetails->getPrice());
689692
$quoteItem->setPriceInclTax($itemTaxDetails->getPriceInclTax());
690693
$quoteItem->setRowTotal($itemTaxDetails->getRowTotal());

0 commit comments

Comments
 (0)