Skip to content

Commit 0215105

Browse files
author
Oleksii Korshenko
authored
MAGETWO-70839: Fixed indexed product positions for anchor categories. #9393
2 parents 87e9a3c + 168a75c commit 0215105

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ protected function createAnchorSelect(\Magento\Store\Model\Store $store)
421421
['ccp' => $this->getTable('catalog_category_product')],
422422
'ccp.category_id = cc2.child_id',
423423
[]
424+
)->joinLeft(
425+
['ccp2' => $this->getTable('catalog_category_product')],
426+
'ccp2.category_id = cc2.parent_id AND ccp.product_id = ccp2.product_id',
427+
[]
424428
)->joinInner(
425429
['cpe' => $this->getTable('catalog_product_entity')],
426430
'ccp.product_id = cpe.entity_id',
@@ -483,7 +487,7 @@ protected function createAnchorSelect(\Magento\Store\Model\Store $store)
483487
[
484488
'category_id' => 'cc.entity_id',
485489
'product_id' => 'ccp.product_id',
486-
'position' => new \Zend_Db_Expr('ccp.position + 10000'),
490+
'position' => new \Zend_Db_Expr($this->connection->getIfNullSql('ccp2.position', 'ccp.position + 10000')),
487491
'is_parent' => new \Zend_Db_Expr('0'),
488492
'store_id' => new \Zend_Db_Expr($store->getId()),
489493
'visibility' => new \Zend_Db_Expr($this->connection->getIfNullSql('cpvs.value', 'cpvd.value')),

0 commit comments

Comments
 (0)