Created
October 27, 2023 17:49
-
-
Save kraken-chris/41800b5d67bff610906d520a541f4214 to your computer and use it in GitHub Desktop.
Fetch all category ids and full category paths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
cce.entity_id AS category_id, | |
GROUP_CONCAT(eav.value ORDER BY parent.path ASC SEPARATOR '/') AS category_path | |
FROM | |
catalog_category_entity AS cce | |
JOIN | |
catalog_category_entity AS parent ON cce.path LIKE CONCAT(parent.path, '%') | |
JOIN | |
catalog_category_entity_varchar AS eav ON parent.row_id = eav.row_id | |
WHERE | |
eav.attribute_id = ( | |
SELECT | |
attribute_id | |
FROM | |
eav_attribute | |
WHERE | |
attribute_code = 'name' AND entity_type_id = ( | |
SELECT | |
entity_type_id | |
FROM | |
eav_entity_type | |
WHERE | |
entity_type_code = 'catalog_category' | |
) | |
) | |
GROUP BY | |
cce.entity_id | |
ORDER BY | |
cce.path; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment