Skip to content

Commit 1ddfde4

Browse files
Merge branch '2.4-develop' into stability_control
2 parents 3541555 + d4a9791 commit 1ddfde4

File tree

33 files changed

+1076
-183
lines changed

33 files changed

+1076
-183
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,9 @@ private function getLinkResolver()
448448
}
449449

450450
/**
451-
* Remove ids of non selected websites from $websiteIds array and return filtered data
451+
* Remove ids of non-selected websites from $websiteIds array and return filtered data
452452
*
453-
* $websiteIds parameter expects array with website ids as keys and 1 (selected) or 0 (non selected) as values
453+
* $websiteIds parameter expects array with website ids as keys and id (selected) or 0 (non-selected) as values
454454
* Only one id (default website ID) will be set to $websiteIds array when the single store mode is turned on
455455
*
456456
* @param array $websiteIds
@@ -461,7 +461,8 @@ private function filterWebsiteIds($websiteIds)
461461
if (!$this->storeManager->isSingleStoreMode()) {
462462
$websiteIds = array_filter((array) $websiteIds);
463463
} else {
464-
$websiteIds[$this->storeManager->getWebsite(true)->getId()] = 1;
464+
$websiteId = $this->storeManager->getWebsite(true)->getId();
465+
$websiteIds[$websiteId] = $websiteId;
465466
}
466467

467468
return $websiteIds;

app/code/Magento/Catalog/Model/Product/Price/Validation/TierPriceValidator.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,19 @@ private function retrieveGroupValue(string $code)
476476
$item = array_shift($items);
477477

478478
if (!$item) {
479+
$this->customerGroupsByCode[$code] = false;
479480
return false;
480481
}
481482

482-
$this->customerGroupsByCode[strtolower($item->getCode())] = $item->getId();
483+
$itemCode = $item->getCode();
484+
$itemId = $item->getId();
485+
486+
if (strtolower($itemCode) !== $code) {
487+
$this->customerGroupsByCode[$code] = false;
488+
return false;
489+
}
490+
491+
$this->customerGroupsByCode[strtolower($itemCode)] = $itemId;
483492
}
484493

485494
return $this->customerGroupsByCode[$code];

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ public function initializeDataProvider()
388388
return [
389389
[
390390
'single_store' => false,
391-
'website_ids' => ['1' => 1, '2' => 1],
392-
'expected_website_ids' => ['1' => 1, '2' => 1],
391+
'website_ids' => ['1' => 1, '2' => 2],
392+
'expected_website_ids' => ['1' => 1, '2' => 2],
393393
'links' => [],
394394
'linkTypes' => ['related', 'upsell', 'crosssell'],
395395
'expected_links' => [],
@@ -423,8 +423,8 @@ public function initializeDataProvider()
423423
// Related links
424424
[
425425
'single_store' => false,
426-
'website_ids' => ['1' => 1, '2' => 1],
427-
'expected_website_ids' => ['1' => 1, '2' => 1],
426+
'website_ids' => ['1' => 1, '2' => 2],
427+
'expected_website_ids' => ['1' => 1, '2' => 2],
428428
'links' => [
429429
'related' => [
430430
0 => [
@@ -449,8 +449,8 @@ public function initializeDataProvider()
449449
// Custom link
450450
[
451451
'single_store' => false,
452-
'website_ids' => ['1' => 1, '2' => 1],
453-
'expected_website_ids' => ['1' => 1, '2' => 1],
452+
'website_ids' => ['1' => 1, '2' => 2],
453+
'expected_website_ids' => ['1' => 1, '2' => 2],
454454
'links' => [
455455
'customlink' => [
456456
0 => [
@@ -475,8 +475,8 @@ public function initializeDataProvider()
475475
// Both links
476476
[
477477
'single_store' => false,
478-
'website_ids' => ['1' => 1, '2' => 1],
479-
'expected_website_ids' => ['1' => 1, '2' => 1],
478+
'website_ids' => ['1' => 1, '2' => 2],
479+
'expected_website_ids' => ['1' => 1, '2' => 2],
480480
'links' => [
481481
'related' => [
482482
0 => [
@@ -515,8 +515,8 @@ public function initializeDataProvider()
515515
// Undefined link type
516516
[
517517
'single_store' => false,
518-
'website_ids' => ['1' => 1, '2' => 1],
519-
'expected_website_ids' => ['1' => 1, '2' => 1],
518+
'website_ids' => ['1' => 1, '2' => 2],
519+
'expected_website_ids' => ['1' => 1, '2' => 2],
520520
'links' => [
521521
'related' => [
522522
0 => [

app/code/Magento/CatalogGraphQl/DataProvider/Product/SearchCriteriaBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function __construct(
9898
public function build(array $args, bool $includeAggregation): SearchCriteriaInterface
9999
{
100100
$searchCriteria = $this->builder->build('products', $args);
101-
$isSearch = !empty($args['search']);
101+
$isSearch = isset($args['search']);
102102
$this->updateRangeFilters($searchCriteria);
103103
if ($includeAggregation) {
104104
$attributeData = $this->eavConfig->getAttribute(Product::ENTITY, 'price');
@@ -122,7 +122,7 @@ public function build(array $args, bool $includeAggregation): SearchCriteriaInte
122122
}
123123

124124
$this->addEntityIdSort($searchCriteria);
125-
$this->addVisibilityFilter($searchCriteria, $isSearch, !empty($args['filter']));
125+
$this->addVisibilityFilter($searchCriteria, $isSearch, !empty($args['filter']['category_id']));
126126

127127
$searchCriteria->setCurrentPage($args['currentPage']);
128128
$searchCriteria->setPageSize($args['pageSize']);

app/code/Magento/CatalogGraphQl/Test/Unit/DataProvider/Product/SearchCriteriaBuilderTest.php

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -97,51 +97,63 @@ public function testBuild(): void
9797
$filter = $this->createMock(Filter::class);
9898

9999
$searchCriteria = $this->getMockBuilder(SearchCriteriaInterface::class)
100-
->disableOriginalConstructor()
101-
->getMockForAbstractClass();
100+
->disableOriginalConstructor()
101+
->getMockForAbstractClass();
102102
$attributeInterface = $this->getMockBuilder(Attribute::class)
103-
->disableOriginalConstructor()
104-
->getMockForAbstractClass();
103+
->disableOriginalConstructor()
104+
->getMockForAbstractClass();
105105

106106
$attributeInterface->setData(['is_filterable' => 0]);
107107

108108
$this->builder->expects($this->any())
109-
->method('build')
110-
->with('products', $args)
111-
->willReturn($searchCriteria);
109+
->method('build')
110+
->with('products', $args)
111+
->willReturn($searchCriteria);
112112
$searchCriteria->expects($this->any())->method('getFilterGroups')->willReturn([]);
113113
$this->eavConfig->expects($this->any())
114-
->method('getAttribute')
115-
->with(Product::ENTITY, 'price')
116-
->willReturn($attributeInterface);
117-
118-
$this->sortOrderBuilder->expects($this->once())
119-
->method('setField')
120-
->with('_id')
121-
->willReturnSelf();
122-
$this->sortOrderBuilder->expects($this->once())
123-
->method('setDirection')
124-
->with('DESC')
125-
->willReturnSelf();
126-
$this->sortOrderBuilder->expects($this->any())
127-
->method('create')
128-
->willReturn([]);
129-
130-
$this->filterBuilder->expects($this->once())
131-
->method('setField')
132-
->with('visibility')
133-
->willReturnSelf();
134-
$this->filterBuilder->expects($this->once())
135-
->method('setValue')
136-
->with("")
137-
->willReturnSelf();
138-
$this->filterBuilder->expects($this->once())
139-
->method('setConditionType')
140-
->with('in')
141-
->willReturnSelf();
142-
143-
$this->filterBuilder->expects($this->once())->method('create')->willReturn($filter);
144-
114+
->method('getAttribute')
115+
->with(Product::ENTITY, 'price')
116+
->willReturn($attributeInterface);
117+
$sortOrderList = ['relevance','_id'];
118+
$sortIncrementIndex = 0;
119+
foreach ($sortOrderList as $sortList) {
120+
$this->sortOrderBuilder->expects($this->at($sortIncrementIndex++))
121+
->method('setField')
122+
->with($sortList)
123+
->willReturnSelf();
124+
$this->sortOrderBuilder->expects($this->at($sortIncrementIndex++))
125+
->method('setDirection')
126+
->with('DESC')
127+
->willReturnSelf();
128+
$this->sortOrderBuilder->expects($this->at($sortIncrementIndex++))
129+
->method('create')
130+
->willReturn([]);
131+
}
132+
$filterOrderList = [1=>'search_term', 2=>'visibility'];
133+
$filterIncrementIndex = 0;
134+
foreach ($filterOrderList as $index => $filterList) {
135+
$this->filterBuilder->expects($this->at($filterIncrementIndex++))
136+
->method('setField')
137+
->with($filterList)
138+
->willReturnSelf();
139+
$this->filterBuilder->expects($this->at($filterIncrementIndex++))
140+
->method('setValue')
141+
->with('')
142+
->willReturnSelf();
143+
if ($index==2) {
144+
$this->filterBuilder->expects($this->at($filterIncrementIndex++))
145+
->method('setConditionType')
146+
->with('in')
147+
->willReturnSelf();
148+
} else {
149+
$this->filterBuilder->expects($this->at($filterIncrementIndex++))
150+
->method('setConditionType')
151+
->with('')
152+
->willReturnSelf();
153+
}
154+
155+
$this->filterBuilder->expects($this->at($filterIncrementIndex++))->method('create')->willReturn($filter);
156+
}
145157
$this->filterGroupBuilder->expects($this->any())
146158
->method('addFilter')
147159
->with($filter)

app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ define([
374374
*/
375375
_sortImages: function (images) {
376376
return _.sortBy(images, function (image) {
377-
return image.position;
377+
return parseInt(image.position, 10);
378378
});
379379
},
380380

app/code/Magento/Customer/Controller/Adminhtml/Group/Save.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ public function execute()
9191
? [] : $this->getRequest()->getParam('customer_group_excluded_websites');
9292
$resultRedirect = $this->resultRedirectFactory->create();
9393
try {
94-
$customerGroupCode = (string)$this->getRequest()->getParam('code');
95-
94+
$customerGroupCode = trim((string)$this->getRequest()->getParam('code'));
9695
if ($id !== null) {
9796
$customerGroup = $this->groupRepository->getById((int)$id);
9897
$customerGroupCode = $customerGroupCode ?: $customerGroup->getCode();

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ public function checkVatNumber($countryCode, $vatNumber, $requesterCountryCode =
212212
$gatewayResponse->setRequestMessage(__('Please enter a valid VAT number.'));
213213
}
214214
} catch (\Exception $exception) {
215+
$this->logger->error(
216+
sprintf('VAT Number validation failed with message: %s', $exception->getMessage()),
217+
['exception' => $exception]
218+
);
219+
215220
$gatewayResponse->setIsValid(false);
216221
$gatewayResponse->setRequestDate('');
217222
$gatewayResponse->setRequestIdentifier('');
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Directory\Setup\Patch\Data;
9+
10+
use Magento\Directory\Setup\DataInstaller;
11+
use Magento\Directory\Setup\DataInstallerFactory;
12+
use Magento\Framework\Setup\ModuleDataSetupInterface;
13+
use Magento\Framework\Setup\Patch\DataPatchInterface;
14+
use Magento\Framework\Setup\Patch\PatchVersionInterface;
15+
16+
/**
17+
* Add Costa Rica States/Regions
18+
*/
19+
class AddDataForCostaRica implements DataPatchInterface, PatchVersionInterface
20+
{
21+
/**
22+
* @var ModuleDataSetupInterface
23+
*/
24+
private $moduleDataSetup;
25+
26+
/**
27+
* @var DataInstallerFactory
28+
*/
29+
private $dataInstallerFactory;
30+
31+
/**
32+
* @param ModuleDataSetupInterface $moduleDataSetup
33+
* @param DataInstallerFactory $dataInstallerFactory
34+
*/
35+
public function __construct(
36+
ModuleDataSetupInterface $moduleDataSetup,
37+
DataInstallerFactory $dataInstallerFactory
38+
) {
39+
$this->moduleDataSetup = $moduleDataSetup;
40+
$this->dataInstallerFactory = $dataInstallerFactory;
41+
}
42+
43+
/**
44+
* @inheritdoc
45+
*/
46+
public function apply()
47+
{
48+
/** @var DataInstaller $dataInstaller */
49+
$dataInstaller = $this->dataInstallerFactory->create();
50+
$dataInstaller->addCountryRegions(
51+
$this->moduleDataSetup->getConnection(),
52+
$this->getDataForCostaRica()
53+
);
54+
55+
return $this;
56+
}
57+
58+
/**
59+
* Costa Rica states data.Pura Vida :)
60+
*
61+
* @return array
62+
*/
63+
private function getDataForCostaRica(): array
64+
{
65+
return [
66+
['CR', 'CR-SJ', 'San José'],
67+
['CR', 'CR-AL', 'Alajuela'],
68+
['CR', 'CR-CA', 'Cartago'],
69+
['CR', 'CR-HE', 'Heredia'],
70+
['CR', 'CR-GU', 'Guanacaste'],
71+
['CR', 'CR-PU', 'Puntarenas'],
72+
['CR', 'CR-LI', 'Limón']
73+
];
74+
}
75+
76+
/**
77+
* @inheritdoc
78+
*/
79+
public static function getDependencies()
80+
{
81+
return [
82+
InitializeDirectoryData::class,
83+
];
84+
}
85+
86+
/**
87+
* @inheritdoc
88+
*/
89+
public function getAliases()
90+
{
91+
return [];
92+
}
93+
94+
/**
95+
* Get version
96+
*
97+
* @return string
98+
*/
99+
public static function getVersion()
100+
{
101+
return '2.4.2';
102+
}
103+
}

app/code/Magento/MediaContentCatalog/Model/ResourceModel/GetEntityContent.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\MediaContentCatalog\Model\ResourceModel;
99

10-
use Magento\Catalog\Model\ResourceModel\Product;
1110
use Magento\Framework\App\ResourceConnection;
1211
use Magento\MediaContentApi\Model\GetEntityContentsInterface;
1312
use Magento\MediaContentApi\Api\Data\ContentIdentityInterface;
@@ -23,11 +22,6 @@ class GetEntityContent implements GetEntityContentsInterface
2322
*/
2423
private $config;
2524

26-
/**
27-
* @var Product
28-
*/
29-
private $productResource;
30-
3125
/**
3226
* @var ResourceConnection
3327
*/
@@ -36,15 +30,12 @@ class GetEntityContent implements GetEntityContentsInterface
3630
/**
3731
* @param Config $config
3832
* @param ResourceConnection $resourceConnection
39-
* @param Product $productResource
4033
*/
4134
public function __construct(
4235
Config $config,
43-
ResourceConnection $resourceConnection,
44-
Product $productResource
36+
ResourceConnection $resourceConnection
4537
) {
4638
$this->config = $config;
47-
$this->productResource = $productResource;
4839
$this->resourceConnection = $resourceConnection;
4940
}
5041

0 commit comments

Comments
 (0)