Wednesday, September 5, 2012

Sql query for getting Category id and name from magento database table


SELECT `entity_id`,`value` FROM `catalog_category_entity_varchar` WHERE `attribute_id` = 3 and
`entity_id` IN(SELECT distinct(`entity_id`)  FROM `catalog_category_entity` WHERE `path` LIKE
'%1/xxx%')
For more than one store
Take the root category id  of store from admin and put it in place of 1/xxx as 1/categoryid
Also you have to search in table `catalog_category_entity_varchar'  for attribute_id  by giving the name of you store root category in place of value field.

SELECT  `attribute_id`   FROM `catalog_category_entity_varchar` WHERE `value` = "your category name";

1 comment: