Skip to content

Commit

Permalink
Merge pull request #4 from valerocompsa/patch-2
Browse files Browse the repository at this point in the history
Update VisibilityFilter.php
  • Loading branch information
0m3r authored Mar 29, 2022
2 parents b0bddb9 + 661c3e1 commit a8b63c5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Model/Search/FilterMapper/VisibilityFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,19 @@ private function applyFilterByJoin(FilterInterface $filter, Select $select)
{
$mainTableAlias = $this->extractTableAliasFromSelect($select);

/** FIX for magento search_tmp insert query hanging */
$optimizedVisibilityQuery = new \Zend_Db_Expr('(SELECT `entity_id`, `store_id`, `attribute_id`, `value` FROM '
. $this->resourceConnection->getTableName('catalog_product_index_eav')
. sprintf(
' WHERE `attribute_id`=%s AND `store_id`=%s'
. ' GROUP BY CONCAT(`entity_id`," ",`attribute_id`," ",`store_id`," ",`value`) )',
$this->getVisibilityAttributeId(),
$this->storeManager->getStore()->getId()
)
);

$select->joinInner(
['visibility_filter' => $this->resourceConnection->getTableName('catalog_product_index_eav')],
['visibility_filter' => $optimizedVisibilityQuery],
$this->conditionManager->combineQueries(
[
sprintf('%s.entity_id = visibility_filter.entity_id', $mainTableAlias),
Expand Down

0 comments on commit a8b63c5

Please sign in to comment.