I want to have all attributes related to a category or it's parents (recursively). This is the database structure.
Categories
--------------------
id
parent_id
Attributes
--------------------
id
attribute_set_id
Attribute_Groups
----------------------------
id
Categories_Attribute_Groups
-----------------------------
category_id
attribute_group_id
Categories_Additional_Attributes
-----------------------------
category_id
attribute_id
An example:
Categories:
id | name | parent_id _______|____________|______________ 1 |Root | null 2 |Parent | 1 3 |Child | 2
There are some attributes and attribute groups that are related to parent, and the child has one attribute (with Categories_Additional_Attributes).
I want an efficient way to get all the attributes that the child and it's parent and the root has.