A
A
alex_belouss2017-05-15 14:48:00
Yii
alex_belouss, 2017-05-15 14:48:00

How to implement properties for different products in an online store?

There is an online clothing store, each product has its own properties, dresses have their own, shirts have their own, bags have their own as in the picture for example:
c1e9dbd6aa894ba9af2a215ab3349dd2.jpg
How to implement it correctly when adding? Simply adding these fields to a table with products is not an option, how can you display the necessary parameters when choosing a category and at the same time all this was stored separately from the products themselves?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Fedorov, 2017-05-15
@qonand

either use a document-oriented database or EAV

I
Ivan Koryukov, 2017-05-15
@MadridianFox

Look towards EAV. This is an approach when you have only the most basic characteristics in the product table, such as availability, price, and specific ones are stored in a separate table, where each row is one property. Well, another table for the names of characteristics. Approximately like this:

goods{id, name, price}
attribute{id, name}
attribute_value{id, id_attr, id_good, value}

There are some options related to the data type of the attribute. Those. there can be one table with attribute values ​​and it has fields for both string value and numeric and date for example. And you can have one table per type.

T
tvsjke, 2017-05-15
@tvsjke

Products
id name table
1 iPhone
3 black Options id name
table 1 white 3 round 4 black Options_to_products table id_product id_option 1 4 1 3 3 1 Something like this, if I understood the question correctly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question