Skip to content

Commit 19e0a8e

Browse files
ENGCOM-8797: MC-38592 Fixed load regions for scope #30755
- Merge Pull Request #30755 from bogutskyy/magento2:MC-38592 - Merged commits: 1. e8507db 2. 228cb68 3. 4e48a7a 4. 165a1c1 5. 3bfc316 6. b611bae 7. cbe1cd9 8. ef066ad 9. 95bf7dc 10. ee50311 11. 9e061d1
2 parents 2e2af0a + 9e061d1 commit 19e0a8e

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed

app/code/Magento/Config/Test/Mftf/Data/CountryOptionConfigData.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,13 @@
2121
<entity name="DefaultAdminAccountAllowCountry" type="checkoutTotalFlagZero">
2222
<data key="value">0</data>
2323
</entity>
24+
<entity name="SetAdminAccountAllowCountryToDefaultForDefaultWebsite" type="default_admin_account_country_options_config_for_default_website">
25+
<requiredEntity type="checkoutTotalFlagZero">DefaultAdminAccountAllowCountry</requiredEntity>
26+
</entity>
27+
<entity name="SetAllowedCountryUsConfig">
28+
<data key="path">general/country/allow</data>
29+
<data key="value">US</data>
30+
<data key="scope">websites</data>
31+
<data key="scope_code">base</data>
32+
</entity>
2433
</entities>

app/code/Magento/Config/Test/Mftf/Metadata/SystemConfigCountriesMeta.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,18 @@
3232
</object>
3333
</object>
3434
</operation>
35+
36+
<operation name="DefaultAdminAccountCountryOptionConfigDefaultWebsite" dataType="default_admin_account_country_options_config_for_default_website" type="create" auth="adminFormKey" url="/admin/system_config/save/section/general/website/1/" method="POST">
37+
<object key="groups" dataType="default_admin_account_country_options_config_for_default_website">
38+
<object key="country" dataType="default_admin_account_country_options_config_for_default_website">
39+
<object key="fields" dataType="default_admin_account_country_options_config_for_default_website">
40+
<object key="allow" dataType="default_admin_account_country_options_config_for_default_website">
41+
<object key="inherit" dataType="checkoutTotalFlagZero">
42+
<field key="value">string</field>
43+
</object>
44+
</object>
45+
</object>
46+
</object>
47+
</object>
48+
</operation>
3549
</operations>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminPlaceOrderWhenCountryAllowedOnlyOnCurrentWebsiteScopeTest">
11+
<annotations>
12+
<features value="Customer"/>
13+
<stories value="Customer Order"/>
14+
<title value="Place an order when country allowed only on current website"/>
15+
<description value="Place an order when country allowed only on current website scope"/>
16+
<severity value="MAJOR"/>
17+
<group value="customer"/>
18+
</annotations>
19+
<before>
20+
<magentoCLI command="config:set --scope={{SetAllowedCountryUsConfig.scope}} --scope-code={{SetAllowedCountryUsConfig.scope_code}} {{SetAllowedCountryUsConfig.path}} {{SetAllowedCountryUsConfig.value}}" stepKey="setAllowedCountryUs"/>
21+
<magentoCLI command="config:set {{SetAllowedCountryUsConfig.path}} ''" stepKey="unselectAllCountriesFromAllowedCounties"/>
22+
<createData entity="SimpleProduct2" stepKey="createSimpleProduct"/>
23+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
24+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
25+
</before>
26+
<after>
27+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
28+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
29+
<createData entity="DisableAdminAccountAllowCountry" stepKey="setDefaultValueForAllowCountries"/>
30+
<createData entity="SetAdminAccountAllowCountryToDefaultForDefaultWebsite" stepKey="setDefaultValueForAllowCountriesForDefaultWebsites"/>
31+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
32+
</after>
33+
34+
<actionGroup ref="NavigateToNewOrderPageExistingCustomerActionGroup" stepKey="navigateToNewOrderWithExistingCustomer">
35+
<argument name="customer" value="$createCustomer$"/>
36+
</actionGroup>
37+
<actionGroup ref="AddSimpleProductToOrderActionGroup" stepKey="addSimpleProductToTheOrder">
38+
<argument name="product" value="$createSimpleProduct$"/>
39+
<argument name="productQty" value="2"/>
40+
</actionGroup>
41+
<actionGroup ref="AdminSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRateShippingMethod"/>
42+
<actionGroup ref="AdminOrderClickSubmitOrderActionGroup" stepKey="submitOrder"/>
43+
<actionGroup ref="VerifyCreatedOrderInformationActionGroup" stepKey="verifyCreatedOrderInformation"/>
44+
</test>
45+
</tests>

app/code/Magento/Directory/Helper/Data.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Directory\Model\ResourceModel\Region\CollectionFactory;
1414
use Magento\Framework\App\Cache\Type\Config;
1515
use Magento\Framework\App\Config\ScopeConfigInterface;
16+
use Magento\Framework\App\Helper\AbstractHelper;
1617
use Magento\Framework\App\Helper\Context;
1718
use Magento\Framework\Json\Helper\Data as JsonData;
1819
use Magento\Store\Model\ScopeInterface;
@@ -25,8 +26,10 @@
2526
* @since 100.0.2
2627
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2728
*/
28-
class Data extends \Magento\Framework\App\Helper\AbstractHelper
29+
class Data extends AbstractHelper
2930
{
31+
private const STORE_ID = 'store_id';
32+
3033
/**
3134
* Config value that lists ISO2 country codes which have optional Zip/Postal pre-configured
3235
*/
@@ -424,6 +427,11 @@ private function getCurrentScope(): array
424427
'type' => ScopeInterface::SCOPE_STORE,
425428
'value' => $request->getParam(ScopeInterface::SCOPE_STORE),
426429
];
430+
} elseif ($request->getParam(self::STORE_ID)) {
431+
$scope = [
432+
'type' => ScopeInterface::SCOPE_STORE,
433+
'value' => $request->getParam(self::STORE_ID),
434+
];
427435
}
428436

429437
return $scope;

0 commit comments

Comments
 (0)