Skip to content

Commit 6226330

Browse files
committed
Merge remote-tracking branch 'tier4/ACP2E-2857' into PR_10_JAN_2024
2 parents 800ff38 + 0b3406d commit 6226330

File tree

8 files changed

+116
-9
lines changed

8 files changed

+116
-9
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained
13+
* from Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
namespace Magento\Catalog\Model\Category\Attribute\Backend;
18+
19+
class DefaultSortby extends Sortby
20+
{
21+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained
13+
* from Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
namespace Magento\Catalog\Setup\Patch\Data;
18+
19+
use Magento\Catalog\Setup\CategorySetup;
20+
use Magento\Catalog\Setup\CategorySetupFactory;
21+
use Magento\Framework\Setup\ModuleDataSetupInterface;
22+
use Magento\Framework\Setup\Patch\DataPatchInterface;
23+
use Magento\Framework\Setup\Patch\PatchInterface;
24+
25+
class UpdateDefaultSortyByBackendType implements DataPatchInterface
26+
{
27+
/**
28+
* @var ModuleDataSetupInterface
29+
*/
30+
private $moduleDataSetup;
31+
32+
/**
33+
* @var CategorySetupFactory
34+
*/
35+
private $categorySetupFactory;
36+
37+
/**
38+
* PatchInitial constructor.
39+
* @param ModuleDataSetupInterface $moduleDataSetup
40+
* @param CategorySetupFactory $categorySetupFactory
41+
*/
42+
public function __construct(
43+
ModuleDataSetupInterface $moduleDataSetup,
44+
CategorySetupFactory $categorySetupFactory
45+
) {
46+
$this->moduleDataSetup = $moduleDataSetup;
47+
$this->categorySetupFactory = $categorySetupFactory;
48+
}
49+
50+
/**
51+
* @inheritdoc
52+
*/
53+
public function apply(): UpdateDefaultSortyByBackendType
54+
{
55+
$mediaBackendModel = \Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby::class;
56+
/** @var CategorySetup $categorySetup */
57+
$categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
58+
$categorySetup->updateAttribute(
59+
'catalog_category',
60+
'default_sort_by',
61+
'backend_model',
62+
$mediaBackendModel
63+
);
64+
65+
return $this;
66+
}
67+
68+
/**
69+
* @inheritdoc
70+
*/
71+
public static function getDependencies()
72+
{
73+
return [];
74+
}
75+
76+
/**
77+
* @inheritdoc
78+
*/
79+
public function getAliases()
80+
{
81+
return [];
82+
}
83+
}

app/code/Magento/Catalog/Test/Fixture/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Category implements RevertibleDataFixtureInterface
2727
'include_in_menu' => true,
2828
'available_sort_by' => [],
2929
'custom_attributes' => [
30-
'default_sort_by' => ['name']
30+
'default_sort_by' => 'position'
3131
],
3232
'extension_attributes' => [],
3333
'created_at' => null,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@
740740
<item name="Magento\Catalog\Model\Product\Attribute\Backend\Category" xsi:type="string">int[]</item>
741741
<item name="Magento\Catalog\Model\Product\Attribute\Backend\Stock" xsi:type="string">Magento\CatalogInventory\Api\Data\StockItemInterface[]</item>
742742
<item name="Magento\Catalog\Model\Category\Attribute\Backend\Sortby" xsi:type="string">string[]</item>
743+
<item name="Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby" xsi:type="string">string</item>
743744
</argument>
744745
</arguments>
745746
</type>

dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,20 +269,21 @@ public function testUpdate()
269269
$this->createdCategories = [$categoryId];
270270
}
271271

272-
/**
273-
* @magentoApiDataFixture Magento/Catalog/_files/category.php
274-
*/
272+
#[
273+
DataFixture(CategoryFixture::class, as: 'category')
274+
]
275275
public function testUpdateWithDefaultSortByAttribute()
276276
{
277-
$categoryId = 333;
277+
$category = $this->fixtures->get('category');
278+
$categoryId = $category->getId();
278279
$categoryData = [
279280
'name' => 'Update Category Test With default_sort_by Attribute',
280281
'is_active' => true,
281282
"available_sort_by" => [],
282283
'custom_attributes' => [
283284
[
284285
'attribute_code' => 'default_sort_by',
285-
'value' => ["name"],
286+
'value' => "price"
286287
],
287288
],
288289
];
@@ -293,7 +294,7 @@ public function testUpdateWithDefaultSortByAttribute()
293294
$category = $model->load($categoryId);
294295
$this->assertTrue((bool)$category->getIsActive(), 'Category "is_active" must equal to true');
295296
$this->assertEquals("Update Category Test With default_sort_by Attribute", $category->getName());
296-
$this->assertEquals("name", $category->getDefaultSortBy());
297+
$this->assertEquals("price", $category->getDefaultSortBy());
297298
$this->createdCategories = [$categoryId];
298299
}
299300

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductAttributeTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function testComplexAttributeTypeResolver()
156156
'catalog_product'
157157
];
158158
$attributeTypes = [
159-
'String[]',
159+
'String',
160160
'String[]',
161161
'Int',
162162
'CatalogInventoryDataStockItemInterface[]',

dev/tests/integration/framework/Magento/TestFramework/ApplicationStateComparator/_files/state-skip-list.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@
314314
Magento\Catalog\Model\Category\Attribute\Backend\Image\Interceptor::class => null,
315315
Magento\Catalog\Model\Attribute\Backend\Startdate\Interceptor::class => null,
316316
Magento\Eav\Model\Entity\Attribute\Backend\Datetime\Interceptor::class => null,
317+
Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby\Interceptor::class => null,
317318
Magento\Catalog\Model\Category\Attribute\Backend\Sortby\Interceptor::class => null,
318319
Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate\Interceptor::class => null,
319320
Magento\Catalog\Model\Attribute\Backend\Customlayoutupdate\Interceptor::class => null,

dev/tests/integration/testsuite/Magento/Eav/Model/TypeLocatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function getExpectedAttributeTypesProvider(): array
193193
'custom_design_to' => 'string',
194194
'available_sort_by' => 'string[]',
195195
'page_layout' => 'string',
196-
'default_sort_by' => 'string[]',
196+
'default_sort_by' => 'string',
197197
'filter_price_range' => 'double',
198198
'custom_layout_update' => 'string',
199199
]

0 commit comments

Comments
 (0)