diff --git a/vendor/magento/module-catalog/Model/ResourceModel/Category/AggregateCount.php b/vendor/magento/module-catalog/Model/ResourceModel/Category/AggregateCount.php index fab2441db26..939f9d354af 100644 --- a/vendor/magento/module-catalog/Model/ResourceModel/Category/AggregateCount.php +++ b/vendor/magento/module-catalog/Model/ResourceModel/Category/AggregateCount.php @@ -8,11 +8,15 @@ namespace Magento\Catalog\Model\ResourceModel\Category; use Magento\Catalog\Model\Category; /** + * Aggregate count for parent category after deleting child category + * * Class AggregateCount */ class AggregateCount { /** + * Reduces children count for parent categories + * * @param Category $category * @return void */ @@ -25,9 +29,7 @@ class AggregateCount */ $parentIds = $category->getParentIds(); if ($parentIds) { - $childDecrease = $category->getChildrenCount() + 1; - // +1 is itself - $data = ['children_count' => new \Zend_Db_Expr('children_count - ' . $childDecrease)]; + $data = ['children_count' => new \Zend_Db_Expr('children_count - 1')]; $where = ['entity_id IN(?)' => $parentIds]; $resourceModel->getConnection()->update($resourceModel->getEntityTable(), $data, $where); }