Skip to content

Commit 0dfd146

Browse files
fixed negative children_count after deleting categories
1 parent 1116437 commit 0dfd146

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Category/AggregateCount.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ public function processDelete(Category $category)
2525
*/
2626
$parentIds = $category->getParentIds();
2727
if ($parentIds) {
28-
$childDecrease = $category->getChildrenCount() + 1;
29-
// +1 is itself
30-
$data = ['children_count' => new \Zend_Db_Expr('children_count - ' . $childDecrease)];
28+
$data = ['children_count' => new \Zend_Db_Expr('children_count - 1')];
3129
$where = ['entity_id IN(?)' => $parentIds];
3230
$resourceModel->getConnection()->update($resourceModel->getEntityTable(), $data, $where);
3331
}

0 commit comments

Comments
 (0)