Skip to content

Commit 6bde7aa

Browse files
authored
Merge branch 'magento-commerce:2.4-develop' into ACP2E-1569
2 parents 677b384 + c9d1397 commit 6bde7aa

File tree

33 files changed

+796
-46
lines changed

33 files changed

+796
-46
lines changed

app/code/Magento/Bundle/Pricing/Adjustment/DefaultSelectionPriceListProvider.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public function getPriceList(Product $bundleProduct, $searchMin, $useRegularPric
8484
[(int)$option->getOptionId()],
8585
$bundleProduct
8686
);
87+
$selectionsCollection->setFlag('has_stock_status_filter', true);
8788
$selectionsCollection->removeAttributeToSelect();
88-
$selectionsCollection->addQuantityFilter();
8989

9090
if (!$useRegularPrice) {
9191
$selectionsCollection->addAttributeToSelect('special_price');
@@ -140,6 +140,9 @@ private function isShouldFindMinOption(Product $bundleProduct, $searchMin)
140140
private function addMiniMaxPriceList(Product $bundleProduct, $selectionsCollection, $searchMin, $useRegularPrice)
141141
{
142142
$selectionsCollection->addPriceFilter($bundleProduct, $searchMin, $useRegularPrice);
143+
if ($bundleProduct->isSalable()) {
144+
$selectionsCollection->addQuantityFilter();
145+
}
143146
$selectionsCollection->setPage(0, 1);
144147

145148
$selection = $selectionsCollection->getFirstItem();

app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/DefaultSelectionPriceListProviderTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,47 @@ public function testGetPriceList(): void
177177
$this->selectionCollection->expects($this->once())
178178
->method('getIterator')
179179
->willReturn(new \ArrayIterator([]));
180+
$this->selectionCollection->expects($this->once())
181+
->method('setFlag')
182+
->with('has_stock_status_filter', true);
180183

181184
$this->model->getPriceList($this->product, false, false);
182185
}
186+
187+
public function testGetPriceListWithSearchMin(): void
188+
{
189+
$option = $this->createMock(Option::class);
190+
$option->expects($this->once())->method('getRequired')
191+
->willReturn(true);
192+
$this->optionsCollection->expects($this->any())
193+
->method('getIterator')
194+
->willReturn(new \ArrayIterator([$option]));
195+
$this->typeInstance->expects($this->any())
196+
->method('getOptionsCollection')
197+
->with($this->product)
198+
->willReturn($this->optionsCollection);
199+
$this->product->expects($this->any())
200+
->method('getTypeInstance')
201+
->willReturn($this->typeInstance);
202+
$this->selectionCollection->expects($this->once())
203+
->method('getFirstItem')
204+
->willReturn($this->createMock(Product::class));
205+
$this->typeInstance->expects($this->once())
206+
->method('getSelectionsCollection')
207+
->willReturn($this->selectionCollection);
208+
$this->selectionCollection->expects($this->once())
209+
->method('setFlag')
210+
->with('has_stock_status_filter', true);
211+
$this->selectionCollection->expects($this->once())
212+
->method('addQuantityFilter');
213+
$this->product->expects($this->once())->method('isSalable')->willReturn(true);
214+
$this->optionsCollection->expects($this->once())
215+
->method('getSize')
216+
->willReturn(1);
217+
$this->optionsCollection->expects($this->once())
218+
->method('addFilter')
219+
->willReturn($this->optionsCollection);
220+
221+
$this->model->getPriceList($this->product, true, false);
222+
}
183223
}

app/code/Magento/CatalogGraphQl/Model/Config/FilterAttributeReader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ private function getFilterType(Attribute $attribute): string
108108
$filterTypeMap = [
109109
'price' => self::FILTER_RANGE_TYPE,
110110
'date' => self::FILTER_RANGE_TYPE,
111+
'datetime' => self::FILTER_RANGE_TYPE,
111112
'select' => self::FILTER_EQUAL_TYPE,
112113
'multiselect' => self::FILTER_EQUAL_TYPE,
113114
'boolean' => self::FILTER_EQUAL_TYPE,

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/ExtractDataFromCategoryTree.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ private function sortTree(array &$tree): array
7070
} elseif (isset($node['children_count'])) {
7171
$node['children_count'] = 0;
7272
}
73+
// redirect_code null will not return , so it will be 0 when there is no redirect error.
74+
if (!isset($node['redirect_code'])) {
75+
$node['redirect_code'] = 0;
76+
}
7377
}
7478

7579
return $tree;
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
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\CatalogGraphQl\Test\Unit\Model\Config;
9+
10+
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
11+
use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection as AttributeCollection;
12+
use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
13+
use Magento\CatalogGraphQl\Model\Config\FilterAttributeReader;
14+
use Magento\Framework\GraphQl\Schema\Type\Entity\MapperInterface;
15+
use PHPUnit\Framework\MockObject\MockObject;
16+
use PHPUnit\Framework\TestCase;
17+
18+
class FilterAttributeReaderTest extends TestCase
19+
{
20+
/**
21+
* @var MapperInterface|MockObject
22+
*/
23+
private $mapperMock;
24+
25+
/**
26+
* @var CollectionFactory|MockObject
27+
*/
28+
private $collectionFactoryMock;
29+
30+
/**
31+
* @var FilterAttributeReader
32+
*/
33+
private $model;
34+
35+
protected function setUp(): void
36+
{
37+
$this->mapperMock = $this->createMock(MapperInterface::class);
38+
$this->collectionFactoryMock = $this->createMock(AttributeCollectionFactory::class);
39+
$this->model = new FilterAttributeReader($this->mapperMock, $this->collectionFactoryMock);
40+
}
41+
42+
/**
43+
* @dataProvider readDataProvider
44+
* @param string $filterableAttrCode
45+
* @param string $filterableAttrInput
46+
* @param string $searchableAttrCode
47+
* @param string $searchableAttrInput
48+
* @param array $fieldsType
49+
*/
50+
public function testRead(
51+
string $filterableAttrCode,
52+
string $filterableAttrInput,
53+
string $searchableAttrCode,
54+
string $searchableAttrInput,
55+
array $fieldsType
56+
): void {
57+
$this->mapperMock->expects(self::once())
58+
->method('getMappedTypes')
59+
->with('filter_attributes')
60+
->willReturn(['product_filter_attributes' => 'ProductAttributeFilterInput']);
61+
62+
$filterableAttributeCollection = $this->createMock(AttributeCollection::class);
63+
$filterableAttributeCollection->expects(self::once())
64+
->method('addHasOptionsFilter')
65+
->willReturnSelf();
66+
$filterableAttributeCollection->expects(self::once())
67+
->method('addIsFilterableFilter')
68+
->willReturnSelf();
69+
$filterableAttribute = $this->createMock(Attribute::class);
70+
$filterableAttributeCollection->expects(self::once())
71+
->method('getItems')
72+
->willReturn(array_filter([11 => $filterableAttribute]));
73+
$searchableAttributeCollection = $this->createMock(AttributeCollection::class);
74+
$searchableAttributeCollection->expects(self::once())
75+
->method('addHasOptionsFilter')
76+
->willReturnSelf();
77+
$searchableAttributeCollection->expects(self::once())
78+
->method('addIsSearchableFilter')
79+
->willReturnSelf();
80+
$searchableAttributeCollection->expects(self::once())
81+
->method('addDisplayInAdvancedSearchFilter')
82+
->willReturnSelf();
83+
$searchableAttribute = $this->createMock(Attribute::class);
84+
$searchableAttributeCollection->expects(self::once())
85+
->method('getItems')
86+
->willReturn(array_filter([21 => $searchableAttribute]));
87+
$this->collectionFactoryMock->expects(self::exactly(2))
88+
->method('create')
89+
->willReturnOnConsecutiveCalls($filterableAttributeCollection, $searchableAttributeCollection);
90+
91+
$filterableAttribute->method('getAttributeCode')
92+
->willReturn($filterableAttrCode);
93+
$filterableAttribute->method('getFrontendInput')
94+
->willReturn($filterableAttrInput);
95+
$searchableAttribute->method('getAttributeCode')
96+
->willReturn($searchableAttrCode);
97+
$searchableAttribute->method('getFrontendInput')
98+
->willReturn($searchableAttrInput);
99+
100+
$config = $this->model->read();
101+
self::assertNotEmpty($config['ProductAttributeFilterInput']);
102+
self::assertCount(count($fieldsType), $config['ProductAttributeFilterInput']['fields']);
103+
foreach ($fieldsType as $attrCode => $fieldType) {
104+
self::assertEquals($fieldType, $config['ProductAttributeFilterInput']['fields'][$attrCode]['type']);
105+
}
106+
}
107+
108+
public function readDataProvider(): array
109+
{
110+
return [
111+
[
112+
'price',
113+
'price',
114+
'sku',
115+
'text',
116+
[
117+
'price' => 'FilterRangeTypeInput',
118+
'sku' => 'FilterEqualTypeInput',
119+
],
120+
],
121+
[
122+
'date_attr',
123+
'date',
124+
'datetime_attr',
125+
'datetime',
126+
[
127+
'date_attr' => 'FilterRangeTypeInput',
128+
'datetime_attr' => 'FilterRangeTypeInput',
129+
],
130+
],
131+
[
132+
'select_attr',
133+
'select',
134+
'multiselect_attr',
135+
'multiselect',
136+
[
137+
'select_attr' => 'FilterEqualTypeInput',
138+
'multiselect_attr' => 'FilterEqualTypeInput',
139+
],
140+
],
141+
[
142+
'text_attr',
143+
'text',
144+
'textarea_attr',
145+
'textarea',
146+
[
147+
'text_attr' => 'FilterMatchTypeInput',
148+
'textarea_attr' => 'FilterMatchTypeInput',
149+
],
150+
],
151+
[
152+
'boolean_attr',
153+
'boolean',
154+
'boolean_attr',
155+
'boolean',
156+
[
157+
'boolean_attr' => 'FilterEqualTypeInput',
158+
],
159+
],
160+
];
161+
}
162+
}

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,9 +2083,13 @@ private function getFileContent(string $path): string
20832083
*/
20842084
private function getRemoteFileContent(string $filename): string
20852085
{
2086-
// phpcs:disable Magento2.Functions.DiscouragedFunction
2087-
$content = file_get_contents($filename);
2088-
// phpcs:enable Magento2.Functions.DiscouragedFunction
2086+
try {
2087+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
2088+
$content = file_get_contents($filename);
2089+
} catch (\Exception $e) {
2090+
$content = false;
2091+
}
2092+
20892093
return $content !== false ? $content : '';
20902094
}
20912095

app/code/Magento/ConfigurableProduct/Model/Plugin/ProductIdentitiesExtender.php

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

88
namespace Magento\ConfigurableProduct\Model\Plugin;
99

10+
use Magento\Catalog\Model\Product\Type as ProductTypes;
1011
use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableType;
1112
use Magento\Catalog\Api\ProductRepositoryInterface;
1213
use Magento\Catalog\Model\Product;
@@ -51,7 +52,7 @@ public function __construct(ConfigurableType $configurableType, ProductRepositor
5152
*/
5253
public function afterGetIdentities(Product $subject, array $identities): array
5354
{
54-
if ($subject->getTypeId() !== ConfigurableType::TYPE_CODE) {
55+
if ($subject->getTypeId() !== ProductTypes::TYPE_SIMPLE) {
5556
return $identities;
5657
}
5758
$parentProductsIdentities = [];

app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/ProductIdentitiesExtenderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Catalog\Api\ProductRepositoryInterface;
1111
use Magento\Catalog\Model\Product;
12+
use Magento\Catalog\Model\Product\Type;
1213
use Magento\ConfigurableProduct\Model\Plugin\ProductIdentitiesExtender;
1314
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
1415
use PHPUnit\Framework\MockObject\MockObject;
@@ -71,7 +72,7 @@ public function testAfterGetIdentities()
7172
->willReturn($productId);
7273
$productMock->expects($this->exactly(2))
7374
->method('getTypeId')
74-
->willReturn(Configurable::TYPE_CODE);
75+
->willReturn(Type::TYPE_SIMPLE);
7576
$this->configurableTypeMock->expects($this->once())
7677
->method('getParentIdsByChild')
7778
->with($productId)

app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function testPrepareWithAddColumn(): void
160160
public function testPrepareWithUpdateColumn(): void
161161
{
162162
$attributeCode = 'billing_attribute_code';
163-
$backendType = 'backend-type';
163+
$frontendInput = 'text';
164164
$attributeData = [
165165
'attribute_code' => 'billing_attribute_code',
166166
'frontend_input' => 'text',
@@ -211,7 +211,7 @@ public function testPrepareWithUpdateColumn(): void
211211
'config',
212212
[
213213
'name' => $attributeCode,
214-
'dataType' => $backendType,
214+
'dataType' => $frontendInput,
215215
'filter' => [
216216
'filterType' => 'text',
217217
'conditionType' => 'like',

app/code/Magento/Customer/Ui/Component/Listing/Columns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function updateColumn(array $attributeData, $newAttributeCode)
171171
$component->getData('config'),
172172
[
173173
'name' => $newAttributeCode,
174-
'dataType' => $attributeData[AttributeMetadata::BACKEND_TYPE],
174+
'dataType' => $attributeData[AttributeMetadata::FRONTEND_INPUT],
175175
'visible' => (bool)$attributeData[AttributeMetadata::IS_VISIBLE_IN_GRID]
176176
]
177177
);

0 commit comments

Comments
 (0)