@@ -2062,29 +2062,25 @@ protected function _applyProductLimitations()
2062
2062
*/
2063
2063
protected function _applyZeroStoreProductLimitations ()
2064
2064
{
2065
- $ filters = $ this ->_productLimitationFilters ;
2065
+ $ filters = $ this ->_productLimitationFilters ;
2066
2066
$ 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
-
2076
2067
$ joinCond = 'cat_pro.product_id = e.entity_id ' ;
2077
2068
2078
2069
$ fromPart = $ this ->getSelect ()->getPart (Select::FROM );
2079
2070
if (isset ($ fromPart ['cat_pro ' ])) {
2080
2071
$ fromPart ['cat_pro ' ]['joinCondition ' ] = $ joinCond ;
2081
2072
$ this ->getSelect ()->setPart (Select::FROM , $ fromPart );
2082
2073
} else {
2074
+ $ conditions = [
2075
+ $ joinCond ,
2076
+ $ this ->getConnection ()->quoteInto ('cat_pro.category_id IN(?) ' , $ categories , 'int ' ),
2077
+ ];
2078
+ $ joinCond = join (' AND ' , $ conditions );
2083
2079
$ this ->getSelect ()->join (
2084
- ['cat_pro ' => $ categoryProductSelect ],
2080
+ ['cat_pro ' => $ this -> getTable ( ' catalog_category_product ' ) ],
2085
2081
$ 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 ' ) ;
2088
2084
}
2089
2085
$ this ->_joinFields ['position ' ] = ['table ' => 'cat_pro ' , 'field ' => 'min_position ' ];
2090
2086
0 commit comments