Magento – get category Ids from MySQL database

Publikováno 7. 1. 2010

When doing imports of products to magento, you often have to set id of category, where each item belongs. Here is a simple SQL query, that will show you the category ids in a tree structure, so it is easy to find the appropriate category id.

SELECT ccev.entity_id AS categoryID, cce.path, ccev.value
FROM catalog_category_entity cce
JOIN catalog_category_entity_varchar ccev ON ( cce.entity_id = ccev.entity_id
AND ccev.attribute_id =31 )
GROUP BY ccev.entity_id
ORDER BY path
LIMIT 1000

The result than looks like this:

categoryID path value
1 1 Root Catalog
2 1/2 Default Category
12 1/2/12 Turistické průvodce
26 1/2/12/26 Česká republika
27 1/2/12/27 Zahraničí
13 1/2/13 Turistické mapy
28 1/2/13/28 Česká republika
29 1/2/13/29 Zahraničí
14 1/2/14 Cykloturistické průvodce
32 1/2/14/32 Česká republika
33 1/2/14/33 Zahraničí
15 1/2/15 Nástěnné mapy
36 1/2/15/36 Česká republika
37 1/2/15/37 Zahraničí
16 1/2/16 GPS navigace

Tento článek byl přidán 7.1.2010 v 11:29 a patří do kategorie Webdesign. Reakce na článek můžete jednoduše sledovat pomocí RSS 2.0 kanálu. Můžete přidat komentář pokud chcete.

Přidat komentář

 


webdesign Jan Zikmund