Skip to content

Commit 6aeb6fe

Browse files
committed
AC711: Fixed code review changes
1 parent 9a5d7a3 commit 6aeb6fe

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,29 +2062,25 @@ protected function _applyProductLimitations()
20622062
*/
20632063
protected function _applyZeroStoreProductLimitations()
20642064
{
2065-
$filters = $this->_productLimitationFilters;
2065+
$filters = $this->_productLimitationFilters;
20662066
$categories = $this->getChildrenCategories((int)$filters['category_id']);
2067-
2068-
$categoryProductSelect = $this->getConnection()->select()
2069-
->from($this->getTable('catalog_category_product'))
2070-
->columns([
2071-
'min_position' => new Zend_Db_Expr('MIN(position)')
2072-
])
2073-
->where('category_id IN (?)', $categories)
2074-
->group('product_id');
2075-
20762067
$joinCond = 'cat_pro.product_id = e.entity_id';
20772068

20782069
$fromPart = $this->getSelect()->getPart(Select::FROM);
20792070
if (isset($fromPart['cat_pro'])) {
20802071
$fromPart['cat_pro']['joinCondition'] = $joinCond;
20812072
$this->getSelect()->setPart(Select::FROM, $fromPart);
20822073
} else {
2074+
$conditions = [
2075+
$joinCond,
2076+
$this->getConnection()->quoteInto('cat_pro.category_id IN(?)', $categories, 'int'),
2077+
];
2078+
$joinCond = join(' AND ', $conditions);
20832079
$this->getSelect()->join(
2084-
['cat_pro' => $categoryProductSelect],
2080+
['cat_pro' => $this->getTable('catalog_category_product')],
20852081
$joinCond,
2086-
['cat_index_position' => 'min_position']
2087-
);
2082+
['cat_index_position' => new Zend_Db_Expr('MIN(cat_pro.position)')]
2083+
)->group('e.entity_id');
20882084
}
20892085
$this->_joinFields['position'] = ['table' => 'cat_pro', 'field' => 'min_position'];
20902086

0 commit comments

Comments
 (0)