Skip to content

Commit e438e74

Browse files
pradeep.rauthanpradeep.rauthan
authored andcommitted
MC-42623:Countries list is incorrect when using different countries per website and Global Customer Account settings
1 parent f6da342 commit e438e74

File tree

8 files changed

+19
-21
lines changed

8 files changed

+19
-21
lines changed

app/code/Magento/Sales/ViewModel/Customer/Address/AddressAttributeFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public function __construct(
3838
*
3939
* @param Collection $collection
4040
* @param string|integer $storeId
41-
* @return Object
41+
* @return Collection
4242
* @throws LocalizedException
4343
*/
44-
public function setScopeFilter(Collection $collection, $storeId)
44+
public function setScopeFilter(Collection $collection, $storeId) : Collection
4545
{
4646
if ($storeId) {
4747
$allowedCountries = $this->allowedCountryReader->getAllowedCountries(

app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_index.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@
4949
<arguments>
5050
<argument name="customerAddressFormatter" xsi:type="object">Magento\Sales\ViewModel\Customer\AddressFormatter</argument>
5151
<argument name="customerAddressCollection" xsi:type="object">Magento\Customer\Model\ResourceModel\Address\Collection</argument>
52-
<argument name="view_model" xsi:type="object">Magento\Sales\ViewModel\Customer\Address\AddressAttributeFilter</argument>
52+
<argument name="customerAddressCollectionAttributeFilter" xsi:type="object">Magento\Sales\ViewModel\Customer\Address\AddressAttributeFilter</argument>
5353
</arguments>
5454
</block>
5555
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Billing\Address" template="Magento_Sales::order/create/form/address.phtml" name="billing_address">
5656
<arguments>
5757
<argument name="customerAddressFormatter" xsi:type="object">Magento\Sales\ViewModel\Customer\AddressFormatter</argument>
5858
<argument name="customerAddressCollection" xsi:type="object">Magento\Customer\Model\ResourceModel\Address\Collection</argument>
59-
<argument name="view_model" xsi:type="object">Magento\Sales\ViewModel\Customer\Address\AddressAttributeFilter</argument>
59+
<argument name="customerAddressCollectionAttributeFilter" xsi:type="object">Magento\Sales\ViewModel\Customer\Address\AddressAttributeFilter</argument>
6060
</arguments>
6161
</block>
6262
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Shipping\Method" template="Magento_Sales::order/create/abstract.phtml" name="shipping_method">

app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_load_block_billing_address.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<argument name="customerAddressFormatter" xsi:type="object">Magento\Sales\ViewModel\Customer\AddressFormatter</argument>
1414
<argument name="customerAddressCollection" xsi:type="object">Magento\Customer\Model\ResourceModel\Address\Collection</argument>
1515
<argument name="billingAddressDataProvider" xsi:type="object">Magento\Sales\ViewModel\Customer\Address\Billing\AddressDataProvider</argument>
16-
<argument name="view_model" xsi:type="object">Magento\Sales\ViewModel\Customer\Address\AddressAttributeFilter</argument>
16+
<argument name="customerAddressCollectionAttributeFilter" xsi:type="object">Magento\Sales\ViewModel\Customer\Address\AddressAttributeFilter</argument>
1717
</arguments>
1818
</block>
1919
</referenceContainer>

app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_load_block_data.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
<arguments>
2525
<argument name="customerAddressFormatter" xsi:type="object">Magento\Sales\ViewModel\Customer\AddressFormatter</argument>
2626
<argument name="customerAddressCollection" xsi:type="object">Magento\Customer\Model\ResourceModel\Address\Collection</argument>
27-
<argument name="view_model" xsi:type="object">Magento\Sales\ViewModel\Customer\Address\AddressAttributeFilter</argument>
27+
<argument name="customerAddressCollectionAttributeFilter" xsi:type="object">Magento\Sales\ViewModel\Customer\Address\AddressAttributeFilter</argument>
2828
</arguments>
2929
</block>
3030
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Billing\Address" template="Magento_Sales::order/create/form/address.phtml" name="billing_address">
3131
<arguments>
3232
<argument name="customerAddressFormatter" xsi:type="object">Magento\Sales\ViewModel\Customer\AddressFormatter</argument>
3333
<argument name="customerAddressCollection" xsi:type="object">Magento\Customer\Model\ResourceModel\Address\Collection</argument>
34-
<argument name="view_model" xsi:type="object">Magento\Sales\ViewModel\Customer\Address\AddressAttributeFilter</argument>
34+
<argument name="customerAddressCollectionAttributeFilter" xsi:type="object">Magento\Sales\ViewModel\Customer\Address\AddressAttributeFilter</argument>
3535
</arguments>
3636
</block>
3737
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Shipping\Method" template="Magento_Sales::order/create/abstract.phtml" name="shipping_method">

app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_load_block_shipping_address.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<arguments>
1313
<argument name="customerAddressFormatter" xsi:type="object">Magento\Sales\ViewModel\Customer\AddressFormatter</argument>
1414
<argument name="customerAddressCollection" xsi:type="object">Magento\Customer\Model\ResourceModel\Address\Collection</argument>
15-
<argument name="view_model" xsi:type="object">Magento\Sales\ViewModel\Customer\Address\AddressAttributeFilter</argument>
15+
<argument name="customerAddressCollectionAttributeFilter" xsi:type="object">Magento\Sales\ViewModel\Customer\Address\AddressAttributeFilter</argument>
1616
</arguments>
1717
</block>
1818
</referenceContainer>

app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
*/
1616

1717
$addressCollection = $block->getData('customerAddressCollection');
18-
$viewModel = $block->getViewModel();
18+
$AddressCollectionAttributeFilter = $block->getData('customerAddressCollectionAttributeFilter');
1919

2020
$addressArray = [];
2121
if ($block->getCustomerId()):
22-
$addressArray = $viewModel->setScopeFilter($addressCollection, $block->getStoreId())
22+
$addressArray = $AddressCollectionAttributeFilter->setScopeFilter($addressCollection, $block->getStoreId())
2323
->setCustomerFilter([$block->getCustomerId()])->toArray();
2424
endif;
2525

dev/tests/integration/testsuite/Magento/Customer/Model/Address/CustomerAddressDataProviderTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@
77

88
namespace Magento\Customer\Model\Address;
99

10-
use Magento\TestFramework\Helper\Bootstrap;
11-
use Magento\TestFramework\ObjectManager;
1210
use Magento\Customer\Api\CustomerRepositoryInterface;
1311
use Magento\Framework\App\Config\ConfigResource\ConfigInterface;
1412
use Magento\Framework\App\Config\ReinitableConfigInterface;
13+
use Magento\Framework\App\Config\ScopeConfigInterface;
1514
use Magento\Framework\App\Config\Storage\Writer;
1615
use Magento\Framework\App\Config\Storage\WriterInterface;
17-
use Magento\Framework\App\Config\ScopeConfigInterface;
16+
use Magento\Framework\Registry;
17+
use Magento\TestFramework\Helper\Bootstrap;
18+
use Magento\TestFramework\ObjectManager;
1819
use PHPUnit\Framework\TestCase;
1920

2021
/**
21-
* Assert that only relavant addresses for the allowed countries under a website/store fetch.
22+
* Assert that only relevant addresses for the allowed countries under a website/store fetch.
2223
*
23-
* @magentoDbIsolation enabled
24+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2425
*/
2526
class CustomerAddressDataProviderTest extends TestCase
2627
{
@@ -51,8 +52,8 @@ protected function setUp(): void
5152
*/
5253
protected function tearDown(): void
5354
{
54-
/** @var \Magento\Framework\Registry $registry */
55-
$registry = $this->objectManager->get(\Magento\Framework\Registry::class);
55+
/** @var Registry $registry */
56+
$registry = $this->objectManager->get(Registry::class);
5657
$registry->unregister('isSecureArea');
5758
$registry->register('isSecureArea', true);
5859

dev/tests/integration/testsuite/Magento/Sales/ViewModel/Customer/Address/AddressAttributeFilterTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
/**
2727
* Assert that only relevant addresses for the allowed countries under a website/store fetch.
2828
*
29-
* @magentoDbIsolation enabled
3029
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3130
*/
3231
class AddressAttributeFilterTest extends TestCase
@@ -94,8 +93,7 @@ protected function tearDown(): void
9493
*
9594
* @dataProvider addressesDataProvider
9695
*
97-
* @param Collection $collection
98-
* @param $customerId
96+
* @param $storeId
9997
* @param $allowedCountries
10098
* @return void
10199
* @throws LocalizedException
@@ -125,7 +123,6 @@ public function testSetScopeFilter($storeId, $allowedCountries) : void
125123
/**
126124
* Data provider for create allowed countries for a particular store.
127125
*
128-
* @param Collection $collection
129126
* @return array
130127
*/
131128
public function addressesDataProvider(): array

0 commit comments

Comments
 (0)