Skip to content

Commit f5f93d0

Browse files
committed
MC-40679: A "Products" page of the Admin panel is constantly loading after sorting by FPT value was applied
1 parent d3f202a commit f5f93d0

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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\Weee\Ui\Component\Listing;
9+
10+
use Magento\Catalog\Ui\Component\Listing\Attribute\Repository;
11+
use Magento\Catalog\Ui\Component\Listing\Columns as DefaultColumns;
12+
use Magento\Weee\Model\Attribute\Backend\Weee\Tax;
13+
14+
/**
15+
* Class Columns
16+
*/
17+
class Columns
18+
{
19+
/**
20+
* @var Repository
21+
*/
22+
private $attributeRepository;
23+
24+
/**
25+
* @param Repository $attributeRepository
26+
*/
27+
public function __construct(
28+
Repository $attributeRepository
29+
) {
30+
$this->attributeRepository = $attributeRepository;
31+
}
32+
33+
/**
34+
* Makes column for FPT attribute in grid not sortable
35+
*
36+
* @param DefaultColumns $subject
37+
*/
38+
public function afterPrepare(DefaultColumns $subject) : void
39+
{
40+
foreach ($this->attributeRepository->getList() as $attribute) {
41+
if ($attribute->getBackendModel() === Tax::class) {
42+
$column = $subject->getComponent($attribute->getAttributeCode());
43+
$columnConfig = $column->getData('config');
44+
$columnConfig['sortable'] = false;
45+
$column->setData('config', $columnConfig);
46+
}
47+
}
48+
}
49+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,7 @@
8484
<type name="Magento\Catalog\Model\ResourceModel\Attribute\RemoveProductAttributeData">
8585
<plugin name="removeWeeAttributesData" type="Magento\Weee\Plugin\Catalog\ResourceModel\Attribute\RemoveProductWeeData" />
8686
</type>
87+
<type name="Magento\Catalog\Ui\Component\Listing\Columns">
88+
<plugin name="changeWeeColumnConfig" type="Magento\Weee\Ui\Component\Listing\Columns"/>
89+
</type>
8790
</config>

dev/tests/integration/testsuite/Magento/Weee/_files/fixed_product_attribute.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
declare(strict_types=1);
88

9+
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
10+
Resolver::getInstance()->requireDataFixture('Magento/Weee/_files/fixed_product_attribute_rollback.php');
11+
912
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
1013

1114
/** @var \Magento\Eav\Model\Entity\Attribute\Set $attributeSet */
@@ -27,6 +30,7 @@
2730
'attribute_group_id' => $attributeGroupId,
2831
'frontend_input' => 'weee',
2932
'frontend_label' => 'fixed product tax',
33+
'is_used_in_grid' => '1',
3034
];
3135

3236
/** @var \Magento\Catalog\Model\Entity\Attribute $attribute */

0 commit comments

Comments
 (0)