Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/MC-30777' into 2.4-develop-pr11
Browse files Browse the repository at this point in the history
  • Loading branch information
serhii-balko committed Feb 4, 2020
2 parents c50b58d + 3056027 commit 9ee5c0a
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions app/code/Magento/Catalog/Ui/Component/Listing/Columns/Websites.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\Catalog\Ui\Component\Listing\Columns;
Expand Down Expand Up @@ -120,31 +119,32 @@ protected function applySorting()
&& !empty($sorting['direction'])
&& $sorting['field'] === $this->getName()
) {
/** @var \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection $collection */
$collection = $this->getContext()->getDataProvider()->getCollection();
$collection
->joinField(
'websites_ids',
'catalog_product_website',
'website_id',
'product_id=entity_id',
null,
'left'
)
->joinTable(
'store_website',
'website_id = websites_ids',
['name'],
null,
'left'
)
->groupByAttribute('entity_id');
$this->resourceHelper->addGroupConcatColumn(
$collection->getSelect(),
$this->websiteNames,
'name'

$select = $collection->getConnection()->select();
$select->from(
['cpw' => $collection->getTable('catalog_product_website')],
['product_id']
)->joinLeft(
['sw' => $collection->getTable('store_website')],
'cpw.website_id = sw.website_id',
[
$this->websiteNames => new \Zend_Db_Expr(
'GROUP_CONCAT(sw.name ORDER BY sw.website_id ASC SEPARATOR \',\')'
)
]
)->group(
'cpw.product_id'
);

$collection->getSelect()->order($this->websiteNames . ' ' . $sorting['direction']);
$collection->getSelect()->joinLeft(
['product_websites' => $select],
'product_websites.product_id = e.entity_id',
[$this->websiteNames]
)->order(
'product_websites.' . $this->websiteNames . ' ' . $sorting['direction']
);
}
}
}

0 comments on commit 9ee5c0a

Please sign in to comment.