A
A
Andrey Boychenko2019-05-08 14:24:44
Database design
Andrey Boychenko, 2019-05-08 14:24:44

Layered structure of categories, subcategories, features and products?

You need to implement the following:
I have: categories, products, characteristics and their values
​​Actually my tables:
Categories
id
title
parent
group_by
Characteristics
id
title Characteristic
values
​​id
value
specification_id
Products
id
title
price
category
Generally speaking, I derive categories using recursion. No problem here. After that, usually by clicking on a category, you need to get the products. I have a different situation. I need to get all feature values ​​that are linked to a feature whose ID is in turn specified in the group_by field of the category table. And only then, by clicking on this value, you need to get the products that have the selected value.
Total - it should look like this:
Category
Subcategory
Value 1 from feature (red)
Products 19
Value 2 from feature (blue)
Products 1
Products 2
Products 3
Products 4
Value 3 from feature (green)
Products 7
Products 6
Products 11
Ideally, I would like to recursively display all categories at once and bind values ​​from groupBy to them. And when you click on the value, asynchronously pull up the necessary goods.
From all of the above, I need another table where the relationship between the value identifier and the product will be stored.
For this, there is a table products_values
​​id
product_id
value_id
But there is one small problem. I don’t even have an idea how to implement this whole thing correctly using eloquent orm. Moreover, I'm not sure if I have the correct database schema and whether it suits the task.
In addition, in one category, there can be a lot of products, respectively, pagination will be used, or rather, products will be loaded in portions of 50-100 items when scrolling down the page.
It is possible to hear advice, perhaps help in implementation? It is painfully interesting how to properly implement such a thing. I would really appreciate any help, thanks!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Skorzhinsky, 2019-05-08
@AndyKorg

5cd2d0d9d16fd804070610.jpeg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question