Skip to content

Instantly share code, notes, and snippets.

@tinchodev
Created June 25, 2018 20:51
Show Gist options
  • Save tinchodev/d4e3587565133594d13a84e7fa4473ab to your computer and use it in GitHub Desktop.
Save tinchodev/d4e3587565133594d13a84e7fa4473ab to your computer and use it in GitHub Desktop.
Fix magento product's categories tree
CREATE TABLE catalog_category_entity_tmp LIKE catalog_category_entity;
INSERT INTO catalog_category_entity_tmp SELECT * FROM catalog_category_entity;
UPDATE catalog_category_entity cce
SET children_count =
(
SELECT count(cce2.entity_id) as children_county
FROM catalog_category_entity_tmp cce2
WHERE PATH LIKE CONCAT(cce.path,'%')
);
DROP TABLE catalog_category_entity_tmp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment