Skip to content

Commit d7918c6

Browse files
authored
Merge branch '2.4-develop' into platform-health
2 parents 099b632 + fdbcc54 commit d7918c6

File tree

27 files changed

+745
-166
lines changed

27 files changed

+745
-166
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminNavigateToProductAttributeEditPageActionGroup">
12+
<annotations>
13+
<description>Navigate to the given product attribute edit page by attribute label</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="ProductAttributeLabel" type="string"/>
17+
</arguments>
18+
19+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="navigateToProductAttributeGrid"/>
20+
<fillField selector="{{AdminProductAttributeGridSection.GridFilterFrontEndLabel}}" userInput="{{ProductAttributeLabel}}" stepKey="fillTheAttributesFilterByLabel"/>
21+
<click selector="{{AdminProductAttributeGridSection.Search}}" stepKey="clickTheSearchButton"/>
22+
<waitForPageLoad stepKey="waitForSearchToComplete"/>
23+
<click selector="{{AdminProductAttributeGridSection.FirstRow}}" stepKey="clickOnTheFirstSearchResultRow"/>
24+
<waitForPageLoad stepKey="waitForAttribiteEditPageToLoad"/>
25+
</actionGroup>
26+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminScopeSelectionShouldBeDisabledOnMediaGalleryProductAttributeEditTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Attributes Updating"/>
14+
<group value="Catalog"/>
15+
<title value="Admin should not able to change Scope of Media Gallery product attribute"/>
16+
<description value="Admin should not able to change Scope of Media Gallery product attribute"/>
17+
<severity value="MAJOR"/>
18+
<useCaseId value="MC-38156"/>
19+
<testCaseId value="AC-1337"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAdmin"/>
23+
</before>
24+
<after>
25+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
26+
</after>
27+
28+
<actionGroup ref="AdminNavigateToProductAttributeEditPageActionGroup" stepKey="navigateToMediaGalleryProductAttribute">
29+
<argument name="ProductAttributeLabel" value="Media Gallery"/>
30+
</actionGroup>
31+
32+
<click selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}" stepKey="clickAdvancedAttributePropertiesSectionToggle"/>
33+
34+
<assertElementContainsAttribute stepKey="assertTheScopeSelectionIsDisabled">
35+
<expectedResult selector="{{AdvancedAttributePropertiesSection.Scope}}" attribute="disabled" type="string"></expectedResult>
36+
</assertElementContainsAttribute>
37+
38+
</test>
39+
</tests>
40+

app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
class Alert extends \Magento\Framework\App\Config\Value
1818
{
1919
/**
20-
* Cron string path
20+
* Cron expression config path
2121
*/
2222
const CRON_STRING_PATH = 'crontab/default/jobs/catalog_product_alert/schedule/cron_expr';
2323

2424
/**
25-
* Cron model path
25+
* Cron model config path
2626
*/
2727
const CRON_MODEL_PATH = 'crontab/default/jobs/catalog_product_alert/run/model';
2828

@@ -71,8 +71,16 @@ public function __construct(
7171
*/
7272
public function afterSave()
7373
{
74-
$time = $this->getData('groups/productalert_cron/fields/time/value');
75-
$frequency = $this->getData('groups/productalert_cron/fields/frequency/value');
74+
$time = $this->getData('groups/productalert_cron/fields/time/value') ?:
75+
explode(
76+
',',
77+
$this->_config->getValue(
78+
'catalog/productalert_cron/time',
79+
$this->getScope(),
80+
$this->getScopeId()
81+
) ?: '0,0,0'
82+
);
83+
$frequency = $this->getValue();
7684

7785
$cronExprArray = [
7886
(int)$time[1], //Minute
@@ -102,6 +110,7 @@ public function afterSave()
102110
self::CRON_MODEL_PATH
103111
)->save();
104112
} catch (\Exception $e) {
113+
// phpcs:ignore Magento2.Exceptions.DirectThrow
105114
throw new \Exception(__('We can\'t save the cron expression.'));
106115
}
107116

app/code/Magento/Customer/Model/Address/CustomerAddressDataProvider.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
namespace Magento\Customer\Model\Address;
99

10+
use Magento\Customer\Model\Config\Share;
11+
use Magento\Directory\Model\AllowedCountries;
12+
use Magento\Framework\App\ObjectManager;
13+
1014
/**
1115
* Provides customer address data.
1216
*/
@@ -24,13 +28,31 @@ class CustomerAddressDataProvider
2428
*/
2529
private $customerAddressDataFormatter;
2630

31+
/**
32+
* @var \Magento\Customer\Model\Config\Share
33+
*/
34+
private $shareConfig;
35+
36+
/**
37+
* @var AllowedCountries
38+
*/
39+
private $allowedCountryReader;
40+
2741
/**
2842
* @param CustomerAddressDataFormatter $customerAddressDataFormatter
43+
* @param Share|null $share
44+
* @param AllowedCountries|null $allowedCountryReader
2945
*/
3046
public function __construct(
31-
CustomerAddressDataFormatter $customerAddressDataFormatter
47+
CustomerAddressDataFormatter $customerAddressDataFormatter,
48+
?Share $share = null,
49+
?AllowedCountries $allowedCountryReader = null
3250
) {
3351
$this->customerAddressDataFormatter = $customerAddressDataFormatter;
52+
$this->shareConfig = $share ?: ObjectManager::getInstance()
53+
->get(Share::class);
54+
$this->allowedCountryReader = $allowedCountryReader ?: ObjectManager::getInstance()
55+
->get(AllowedCountries::class);
3456
}
3557

3658
/**
@@ -52,8 +74,14 @@ public function getAddressDataByCustomer(
5274
return [];
5375
}
5476

77+
$allowedCountries = $this->allowedCountryReader->getAllowedCountries();
5578
$customerAddresses = [];
5679
foreach ($customerOriginAddresses as $address) {
80+
// Checks if a country id present in the allowed countries list.
81+
if ($this->shareConfig->isGlobalScope() && !in_array($address->getCountryId(), $allowedCountries)) {
82+
continue;
83+
}
84+
5785
$customerAddresses[$address->getId()] = $this->customerAddressDataFormatter->prepareAddress($address);
5886
}
5987

app/code/Magento/Customer/Model/Plugin/AllowedCountries.php

Lines changed: 0 additions & 65 deletions
This file was deleted.

app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsites.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
use Magento\Eav\Model\Entity\Attribute\Source\Table;
2020
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory as OptionCollectionFactory;
2121
use Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory as AttrubuteOptionFactory;
22+
use Magento\Framework\App\ObjectManager;
2223
use Magento\Store\Model\ScopeInterface;
2324
use Magento\Store\Model\StoreManagerInterface;
25+
use Magento\Framework\App\Request\Http;
26+
use Magento\Customer\Api\CustomerRepositoryInterface;
2427

2528
/**
2629
* Return allowed countries for specified website
@@ -52,26 +55,44 @@ class CountryWithWebsites extends Table
5255
*/
5356
private $shareConfig;
5457

58+
/**
59+
* @var Http
60+
*/
61+
private $request;
62+
63+
/**
64+
* @var CustomerRepositoryInterface
65+
*/
66+
private $customerRepository;
67+
5568
/**
5669
* @param OptionCollectionFactory $attrOptionCollectionFactory
5770
* @param AttrubuteOptionFactory $attrOptionFactory
5871
* @param CountryCollectionFactory $countriesFactory
5972
* @param AllowedCountries $allowedCountriesReader
6073
* @param StoreManagerInterface $storeManager
6174
* @param Share $shareConfig
75+
* @param Http|null $request
76+
* @param CustomerRepositoryInterface|null $customerRepository
6277
*/
6378
public function __construct(
6479
OptionCollectionFactory $attrOptionCollectionFactory,
6580
AttrubuteOptionFactory $attrOptionFactory,
6681
CountryCollectionFactory $countriesFactory,
6782
AllowedCountries $allowedCountriesReader,
6883
StoreManagerInterface $storeManager,
69-
CustomerShareConfig $shareConfig
84+
CustomerShareConfig $shareConfig,
85+
?Http $request = null,
86+
?CustomerRepositoryInterface $customerRepository = null
7087
) {
7188
$this->countriesFactory = $countriesFactory;
7289
$this->allowedCountriesReader = $allowedCountriesReader;
7390
$this->storeManager = $storeManager;
7491
$this->shareConfig = $shareConfig;
92+
$this->request = $request
93+
?? ObjectManager::getInstance()->get(Http::class);
94+
$this->customerRepository = $customerRepository
95+
?? ObjectManager::getInstance()->get(CustomerRepositoryInterface::class);
7596
parent::__construct($attrOptionCollectionFactory, $attrOptionFactory);
7697
}
7798

@@ -98,7 +119,18 @@ public function getAllOptions($withEmpty = true, $defaultValues = false)
98119

99120
$allowedCountries = array_unique(array_merge([], ...$allowedCountries));
100121
} else {
101-
$allowedCountries = $this->allowedCountriesReader->getAllowedCountries();
122+
// Address can be added only for the allowed country list.
123+
$storeId = null;
124+
$customerId = $this->request->getParam('parent_id') ?? null;
125+
if ($customerId) {
126+
$customer = $this->customerRepository->getById($customerId);
127+
$storeId = $customer->getStoreId();
128+
}
129+
130+
$allowedCountries = $this->allowedCountriesReader->getAllowedCountries(
131+
ScopeInterface::SCOPE_WEBSITE,
132+
$storeId
133+
);
102134
}
103135

104136
$this->options = $this->createCountriesCollection()

app/code/Magento/Customer/Test/Unit/Model/Plugin/AllowedCountriesTest.php

Lines changed: 0 additions & 67 deletions
This file was deleted.

app/code/Magento/Customer/etc/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,6 @@
366366
<type name="Magento\Customer\Api\CustomerRepositoryInterface">
367367
<plugin name="transactionWrapper" type="Magento\Customer\Model\Plugin\CustomerRepository\TransactionWrapper" sortOrder="-1"/>
368368
</type>
369-
<type name="Magento\Directory\Model\AllowedCountries">
370-
<plugin name="customerAllowedCountries" type="Magento\Customer\Model\Plugin\AllowedCountries"/>
371-
</type>
372369
<type name="Magento\Framework\App\ActionInterface">
373370
<plugin name="customerNotification" type="Magento\Customer\Model\Plugin\CustomerNotification"/>
374371
</type>

0 commit comments

Comments
 (0)