Created
August 16, 2017 22:17
-
-
Save anotherxx/4e5eab7390352f931682ac96fd301625 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For categories: | |
ID | Name | Parent_ID | |
(Parent ID is for category tree) | |
For products: | |
ID | Category_ID | Name | Description | Other | |
Let's say the category tree is like | |
Computers [ID: 1 | Parent: 0] | |
|-Laptops [ID: 2 | Parent: 1] | |
|-Desktop [ID: 3 | Parent: 1] | |
|-Printers [ID: 4 | Parent: 1] | |
| |-Brand #1 [ID: 5 | Parent: 4] | |
| |-Brand #2 [ID: 6 | Parent: 4] | |
|-Other stuff [ID: 7 | Parent: 1] | |
Then, if you want to display all products from from, for example, Printers, just do a recursion getting all items from Printers category and its subcategories. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment