Skip to content

Commit 9ee5c0a

Browse files
committed
Merge remote-tracking branch 'origin/MC-30777' into 2.4-develop-pr11
2 parents c50b58d + 3056027 commit 9ee5c0a

File tree

1 file changed

+23
-23
lines changed
  • app/code/Magento/Catalog/Ui/Component/Listing/Columns

1 file changed

+23
-23
lines changed

app/code/Magento/Catalog/Ui/Component/Listing/Columns/Websites.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\Catalog\Ui\Component\Listing\Columns;
@@ -120,31 +119,32 @@ protected function applySorting()
120119
&& !empty($sorting['direction'])
121120
&& $sorting['field'] === $this->getName()
122121
) {
122+
/** @var \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection $collection */
123123
$collection = $this->getContext()->getDataProvider()->getCollection();
124-
$collection
125-
->joinField(
126-
'websites_ids',
127-
'catalog_product_website',
128-
'website_id',
129-
'product_id=entity_id',
130-
null,
131-
'left'
132-
)
133-
->joinTable(
134-
'store_website',
135-
'website_id = websites_ids',
136-
['name'],
137-
null,
138-
'left'
139-
)
140-
->groupByAttribute('entity_id');
141-
$this->resourceHelper->addGroupConcatColumn(
142-
$collection->getSelect(),
143-
$this->websiteNames,
144-
'name'
124+
125+
$select = $collection->getConnection()->select();
126+
$select->from(
127+
['cpw' => $collection->getTable('catalog_product_website')],
128+
['product_id']
129+
)->joinLeft(
130+
['sw' => $collection->getTable('store_website')],
131+
'cpw.website_id = sw.website_id',
132+
[
133+
$this->websiteNames => new \Zend_Db_Expr(
134+
'GROUP_CONCAT(sw.name ORDER BY sw.website_id ASC SEPARATOR \',\')'
135+
)
136+
]
137+
)->group(
138+
'cpw.product_id'
145139
);
146140

147-
$collection->getSelect()->order($this->websiteNames . ' ' . $sorting['direction']);
141+
$collection->getSelect()->joinLeft(
142+
['product_websites' => $select],
143+
'product_websites.product_id = e.entity_id',
144+
[$this->websiteNames]
145+
)->order(
146+
'product_websites.' . $this->websiteNames . ' ' . $sorting['direction']
147+
);
148148
}
149149
}
150150
}

0 commit comments

Comments
 (0)