Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AggregateCount.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
19  public function processDelete(Category $category)
20  {
22  $resourceModel = $category->getResource();
26  $parentIds = $category->getParentIds();
27  if ($parentIds) {
28  $childDecrease = $category->getChildrenCount() + 1;
29  // +1 is itself
30  $data = ['children_count' => new \Zend_Db_Expr('children_count - ' . $childDecrease)];
31  $where = ['entity_id IN(?)' => $parentIds];
32  $resourceModel->getConnection()->update($resourceModel->getEntityTable(), $data, $where);
33  }
34  }
35 }
$resourceModel
Definition: tablerates.php:10