|
3 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
6 |
| - |
7 | 6 | declare(strict_types=1);
|
8 | 7 |
|
9 | 8 | namespace Magento\Catalog\Ui\Component\Listing\Columns;
|
@@ -120,31 +119,32 @@ protected function applySorting()
|
120 | 119 | && !empty($sorting['direction'])
|
121 | 120 | && $sorting['field'] === $this->getName()
|
122 | 121 | ) {
|
| 122 | + /** @var \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection $collection */ |
123 | 123 | $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' |
145 | 139 | );
|
146 | 140 |
|
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 | + ); |
148 | 148 | }
|
149 | 149 | }
|
150 | 150 | }
|
0 commit comments