Skip to content

Commit e42ed8d

Browse files
authored
Merge pull request #5619 from magento-tsg-csl3/2.4-develop-pr23
[TSG-CSL3] For 2.4 (pr23)
2 parents bb7e08f + 5eccdf2 commit e42ed8d

File tree

28 files changed

+765
-123
lines changed

28 files changed

+765
-123
lines changed

app/code/Magento/Checkout/CustomerData/DefaultItem.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\Catalog\Model\Product\Configuration\Item\ItemResolverInterface;
1111

1212
/**
13-
* Default item
13+
* Default cart item
1414
*/
1515
class DefaultItem extends AbstractItem
1616
{
@@ -78,7 +78,7 @@ public function __construct(
7878
}
7979

8080
/**
81-
* {@inheritdoc}
81+
* @inheritdoc
8282
*/
8383
protected function doGetItemData()
8484
{
@@ -106,6 +106,7 @@ protected function doGetItemData()
106106
],
107107
'canApplyMsrp' => $this->msrpHelper->isShowBeforeOrderConfirm($this->item->getProduct())
108108
&& $this->msrpHelper->isMinimalPriceLessMsrp($this->item->getProduct()),
109+
'message' => $this->item->getMessage(),
109110
];
110111
}
111112

@@ -121,6 +122,8 @@ protected function getOptionList()
121122
}
122123

123124
/**
125+
* Returns product for thumbnail.
126+
*
124127
* @return \Magento\Catalog\Model\Product
125128
* @codeCoverageIgnore
126129
*/
@@ -130,6 +133,8 @@ protected function getProductForThumbnail()
130133
}
131134

132135
/**
136+
* Returns product.
137+
*
133138
* @return \Magento\Catalog\Model\Product
134139
* @codeCoverageIgnore
135140
*/

app/code/Magento/Checkout/Test/Unit/CustomerData/DefaultItemTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Checkout\Test\Unit\CustomerData;
77

88
use Magento\Catalog\Model\Product\Configuration\Item\ItemResolverInterface;
9+
use PHPUnit\Framework\MockObject\MockObject;
910

1011
class DefaultItemTest extends \PHPUnit\Framework\TestCase
1112
{
@@ -25,7 +26,7 @@ class DefaultItemTest extends \PHPUnit\Framework\TestCase
2526
private $configurationPool;
2627

2728
/**
28-
* @var ItemResolverInterface|\PHPUnit_Framework_MockObject_MockObject
29+
* @var ItemResolverInterface|MockObject
2930
*/
3031
private $itemResolver;
3132

@@ -102,5 +103,6 @@ public function testGetItemData()
102103
$this->assertArrayHasKey('product_price_value', $itemData);
103104
$this->assertArrayHasKey('product_image', $itemData);
104105
$this->assertArrayHasKey('canApplyMsrp', $itemData);
106+
$this->assertArrayHasKey('message', $itemData);
105107
}
106108
}

app/code/Magento/Checkout/view/frontend/web/template/minicart/item/default.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,7 @@
112112
</div>
113113
</div>
114114
</div>
115+
<div class="message notice" if="message">
116+
<div data-bind="text: message"></div>
117+
</div>
115118
</li>

app/code/Magento/Customer/Controller/Account/CreatePost.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ class CreatePost extends AbstractAccount implements CsrfAwareActionInterface, Ht
149149
*/
150150
private $customerRepository;
151151

152+
/**
153+
* @var ScopeConfigInterface
154+
*/
155+
private $scopeConfig;
156+
152157
/**
153158
* @param Context $context
154159
* @param Session $customerSession
@@ -266,9 +271,15 @@ protected function extractAddress()
266271
$addressData = [];
267272

268273
$regionDataObject = $this->regionDataFactory->create();
274+
$userDefinedAttr = $this->getRequest()->getParam('address') ?: [];
269275
foreach ($allowedAttributes as $attribute) {
270276
$attributeCode = $attribute->getAttributeCode();
271-
$value = $this->getRequest()->getParam($attributeCode);
277+
if ($attribute->isUserDefined()) {
278+
$value = array_key_exists($attributeCode, $userDefinedAttr) ? $userDefinedAttr[$attributeCode] : null;
279+
} else {
280+
$value = $this->getRequest()->getParam($attributeCode);
281+
}
282+
272283
if ($value === null) {
273284
continue;
274285
}
@@ -283,6 +294,9 @@ protected function extractAddress()
283294
$addressData[$attributeCode] = $value;
284295
}
285296
}
297+
$addressData = $addressForm->compactData($addressData);
298+
unset($addressData['region_id'], $addressData['region']);
299+
286300
$addressDataObject = $this->addressDataFactory->create();
287301
$this->dataObjectHelper->populateWithArray(
288302
$addressDataObject,

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

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66

77
namespace Magento\Directory\Helper;
88

9+
use Magento\Directory\Model\AllowedCountries;
910
use Magento\Directory\Model\Currency;
1011
use Magento\Directory\Model\CurrencyFactory;
1112
use Magento\Directory\Model\ResourceModel\Country\Collection;
1213
use Magento\Directory\Model\ResourceModel\Region\CollectionFactory;
1314
use Magento\Framework\App\Cache\Type\Config;
15+
use Magento\Framework\App\Config\ScopeConfigInterface;
1416
use Magento\Framework\App\Helper\Context;
1517
use Magento\Framework\Json\Helper\Data as JsonData;
1618
use Magento\Store\Model\ScopeInterface;
@@ -21,6 +23,7 @@
2123
*
2224
* @api
2325
* @since 100.0.2
26+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2427
*/
2528
class Data extends \Magento\Framework\App\Helper\AbstractHelper
2629
{
@@ -156,6 +159,7 @@ public function getRegionCollection()
156159
{
157160
if (!$this->_regionCollection) {
158161
$this->_regionCollection = $this->_regCollectionFactory->create();
162+
// phpstan:ignore
159163
$this->_regionCollection->addCountryFilter($this->getAddress()->getCountryId())->load();
160164
}
161165
return $this->_regionCollection;
@@ -185,7 +189,9 @@ public function getRegionJson()
185189
{
186190
\Magento\Framework\Profiler::start('TEST: ' . __METHOD__, ['group' => 'TEST', 'method' => __METHOD__]);
187191
if (!$this->_regionJson) {
188-
$cacheKey = 'DIRECTORY_REGIONS_JSON_STORE' . $this->_storeManager->getStore()->getId();
192+
$scope = $this->getCurrentScope();
193+
$scopeKey = $scope['value'] ? '_' . implode('_', $scope) : null;
194+
$cacheKey = 'DIRECTORY_REGIONS_JSON_STORE' . $scopeKey;
189195
$json = $this->_configCacheType->load($cacheKey);
190196
if (empty($json)) {
191197
$regions = $this->getRegionData();
@@ -344,10 +350,13 @@ public function getDefaultCountry($store = null)
344350
*/
345351
public function getRegionData()
346352
{
347-
$countryIds = [];
348-
foreach ($this->getCountryCollection() as $country) {
349-
$countryIds[] = $country->getCountryId();
350-
}
353+
$scope = $this->getCurrentScope();
354+
$allowedCountries = $this->scopeConfig->getValue(
355+
AllowedCountries::ALLOWED_COUNTRIES_PATH,
356+
$scope['type'],
357+
$scope['value']
358+
);
359+
$countryIds = explode(',', $allowedCountries);
351360
$collection = $this->_regCollectionFactory->create();
352361
$collection->addCountryFilter($countryIds)->load();
353362
$regions = [
@@ -392,4 +401,31 @@ public function getWeightUnit()
392401
{
393402
return $this->scopeConfig->getValue(self::XML_PATH_WEIGHT_UNIT, ScopeInterface::SCOPE_STORE);
394403
}
404+
405+
/**
406+
* Get current scope from request
407+
*
408+
* @return array
409+
*/
410+
private function getCurrentScope(): array
411+
{
412+
$scope = [
413+
'type' => ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
414+
'value' => null,
415+
];
416+
$request = $this->_getRequest();
417+
if ($request->getParam(ScopeInterface::SCOPE_WEBSITE)) {
418+
$scope = [
419+
'type' => ScopeInterface::SCOPE_WEBSITE,
420+
'value' => $request->getParam(ScopeInterface::SCOPE_WEBSITE),
421+
];
422+
} elseif ($request->getParam(ScopeInterface::SCOPE_STORE)) {
423+
$scope = [
424+
'type' => ScopeInterface::SCOPE_STORE,
425+
'value' => $request->getParam(ScopeInterface::SCOPE_STORE),
426+
];
427+
}
428+
429+
return $scope;
430+
}
395431
}

0 commit comments

Comments
 (0)