Hello,
I have a shop and I have many categories and subcategories. I want to export a list (I dont care about the file format) with all my categories and their id.
I tries to login to my database and check it from there but I have a small problem with that.
My categories are like this this:
Woman
- - Clothes
- - - - Tshirts
- - - - something
- - - - something
Man
- - Clothes
- - - - Tshirts
- - - - something
- - - - something
So there are subcategories with the same name but with a unique id. When I check the files on the database I see the (`category_id`, `language_id`, `name`, `description`, `meta_title`, `meta_description`, `meta_keyword`).
The problem is that I see for example two or more times a subcategory named "clothes" but I dont know which is the parent category.
My question is simple, is there a way to know which is the parent category of each category on the oc_category_description in the database.
Even better, is there a way to export all my categories to a file. I need the ( `category_id`, `name`) in a tree structure?
Thank you
Try this;
select d.category_id as P_ID,
d.name as Parent,
'' as C_ID,
'' as Child
from oc_category_description d
join oc_category c on c.category_id = d.category_id
where c.top=1
union
select c.parent_id as P_ID,
( select name from oc_category_description where category_id = c.parent_id ) as Parent,
d.category_id as C_ID,
d.name as Child
from oc_category_description d
join oc_category c on c.category_id = d.category_id
where c.top=0
order by 2,4
select d.category_id as P_ID,
d.name as Parent,
'' as C_ID,
'' as Child
from oc_category_description d
join oc_category c on c.category_id = d.category_id
where c.top=1
union
select c.parent_id as P_ID,
( select name from oc_category_description where category_id = c.parent_id ) as Parent,
d.category_id as C_ID,
d.name as Child
from oc_category_description d
join oc_category c on c.category_id = d.category_id
where c.top=0
order by 2,4
Who is online
Users browsing this forum: No registered users and 9 guests