Skip to content

Instantly share code, notes, and snippets.

@Nolwennig
Last active December 8, 2020 13:30
Show Gist options
  • Save Nolwennig/a90670efe9bb113b525901c8e54a22a8 to your computer and use it in GitHub Desktop.
Save Nolwennig/a90670efe9bb113b525901c8e54a22a8 to your computer and use it in GitHub Desktop.
Magento-{1.{7-9}|2} simpleCategoryTree sql request > .csv

Magento simpleCategoryTree.csv

command from cli

mysql -uroot -proot magento -e "here sql query" > category_tree.csv; 

sql query

SELECT 
  CONCAT(catalog_category_entity.path, ';') AS 'Chemin;',
  CONCAT(catalog_category_entity.position, ';') AS 'Position;',
  CONCAT(catalog_category_entity.entity_id,';') AS 'ID;',
  CONCAT(catalog_category_entity_varchar.value, ';') AS 'Nom;'
FROM 
  catalog_category_entity, 
  catalog_category_entity_varchar 
WHERE 
  catalog_category_entity.entity_id = catalog_category_entity_varchar.entity_id 
AND 
  catalog_category_entity_varchar.attribute_id = (
    SELECT 
      attribute_id 
    FROM
      eav_attribute 
    WHERE
      eav_attribute.attribute_code = 'name'
    AND
      eav_attribute.entity_type_id = 3
  )
ORDER BY 
  catalog_category_entity.path, 
  catalog_category_entity.position;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment