Skip to content

Commit 9e6ad2f

Browse files
author
Evgeni Obukhovsky
committed
Fixed indexed product positions for anchor categories.
1 parent a9e8595 commit 9e6ad2f

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
@@ -431,6 +431,10 @@ protected function createAnchorSelect(\Magento\Store\Model\Store $store)
431431
['ccp' => $this->getTable('catalog_category_product')],
432432
'ccp.category_id = cc2.child_id',
433433
[]
434+
)->joinLeft(
435+
['ccp2' => $this->getTable('catalog_category_product')],
436+
'ccp2.category_id = cc2.parent_id AND ccp.product_id = ccp2.product_id',
437+
[]
434438
)->joinInner(
435439
['cpe' => $this->getTable('catalog_product_entity')],
436440
'ccp.product_id = cpe.entity_id',
@@ -493,7 +497,7 @@ protected function createAnchorSelect(\Magento\Store\Model\Store $store)
493497
[
494498
'category_id' => 'cc.entity_id',
495499
'product_id' => 'ccp.product_id',
496-
'position' => new \Zend_Db_Expr('ccp.position + 10000'),
500+
'position' => new \Zend_Db_Expr($this->connection->getIfNullSql('ccp2.position', 'ccp.position + 10000')),
497501
'is_parent' => new \Zend_Db_Expr('0'),
498502
'store_id' => new \Zend_Db_Expr($store->getId()),
499503
'visibility' => new \Zend_Db_Expr($this->connection->getIfNullSql('cpvs.value', 'cpvd.value')),

0 commit comments

Comments
 (0)