Skip to content

Commit 3995243

Browse files
committed
Merge branch 'MC-30775' of https://github.com/magento-tango/magento2ce into PR-2020-02-05
2 parents 11d3487 + 47e0f5c commit 3995243

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;
@@ -121,31 +120,32 @@ protected function applySorting()
121120
&& !empty($sorting['direction'])
122121
&& $sorting['field'] === $this->getName()
123122
) {
123+
/** @var \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection $collection */
124124
$collection = $this->getContext()->getDataProvider()->getCollection();
125-
$collection
126-
->joinField(
127-
'websites_ids',
128-
'catalog_product_website',
129-
'website_id',
130-
'product_id=entity_id',
131-
null,
132-
'left'
133-
)
134-
->joinTable(
135-
'store_website',
136-
'website_id = websites_ids',
137-
['name'],
138-
null,
139-
'left'
140-
)
141-
->groupByAttribute('entity_id');
142-
$this->resourceHelper->addGroupConcatColumn(
143-
$collection->getSelect(),
144-
$this->websiteNames,
145-
'name'
125+
126+
$select = $collection->getConnection()->select();
127+
$select->from(
128+
['cpw' => $collection->getTable('catalog_product_website')],
129+
['product_id']
130+
)->joinLeft(
131+
['sw' => $collection->getTable('store_website')],
132+
'cpw.website_id = sw.website_id',
133+
[
134+
$this->websiteNames => new \Zend_Db_Expr(
135+
'GROUP_CONCAT(sw.name ORDER BY sw.website_id ASC SEPARATOR \',\')'
136+
)
137+
]
138+
)->group(
139+
'cpw.product_id'
146140
);
147141

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

0 commit comments

Comments
 (0)