You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The children_count field in Magento can sometimes become inaccurate if you have created a category via the PHP API and set an entity_id whilst doing so. It is due to part of the after_save mechanism which overrides the children_count parameter (even if explicitly set via $_category->setChildrenCount()).
Fix
A SQL fix is available (from that same blog):
CREATETABLEcatalog_category_entity_tmpLIKE catalog_category_entity;
INSERT INTO catalog_category_entity_tmp SELECT*FROM catalog_category_entity;
UPDATE catalog_category_entity cce
SET children_count =
(
SELECTcount(cce2.entity_id)-1as children_county
FROM catalog_category_entity_tmp cce2
WHEREPATHLIKE CONCAT(cce.path,'%')
);
DROPTABLE catalog_category_entity_tmp;
This query seems to work, but it's after-the-fact of course and we would have to build this into an Indexer or Cache clearing button or something like that for it to work.
The impact (afaik) is:
Admin Category tree showing that a category has children, while it has none (impact limited)
Admin Category tree showing no children when there are children (bigger impact). This is because the value of children_count may even become negative.
I'm open to a deeper fix but it seems we can stop negative values, and perhaps we can do something to remove the has-children icon in case children = [] (fixes point 1).
The text was updated successfully, but these errors were encountered:
Steps to reproduce (*)
Steps are described at https://www.sonassi.com/blog/magento-kb/magento-category-children-count-fix
Fix
A SQL fix is available (from that same blog):
This query seems to work, but it's after-the-fact of course and we would have to build this into an Indexer or Cache clearing button or something like that for it to work.
The impact (afaik) is:
children_count
may even become negative.I'm open to a deeper fix but it seems we can stop negative values, and perhaps we can do something to remove the has-children icon in case
children = []
(fixes point 1).The text was updated successfully, but these errors were encountered: