Custom Product Attributes for Ecommerce Website

I am creating a database using MySQL 5 for an e-commerce website. I want the database as flexible as possible so that website owners can add custom attributes for different types of products. For example, they may have a product that has 4 shirt sizes and 3 colors for each size available, or a product that has 6 shirt sizes, 4 colors for each size, and possibly a 3rd attribute.

The problem I am facing is that they should be able to control the quantity for the product based on its various attributes, and not the product itself. A company may have a product that has 25 pieces in one style and color, but has 13 in a warehouse of a different size and color combination.

Is there a good solution on how to structure this in a MySQL database? Currently, I have a table in which the product identifier will be stored, the number and attributes will be combined in 1 field using the "key: value" syntax, separated by a comma.

This is my first time trying to create such a system. Any information / help would be greatly appreciated. If you need more information, I can also provide this.


Hey guys, I really appreciate the recommendation. But for this Derived Item method, would I need to create a different database table for each type of product, since the products could have variable attributes associated with them?

+3
source share
4 answers

The simplest solution, obviously, is to make each combination with a shirt and a completely separate element and abandon the concept of an attribute. I believe that this is how real stores work. This makes sense when you consider how often all the underlying elements change.

, DerivedItem, , BaseItem. .

+3

, .

, .

( ..) , (, , ..).

, . , "-" " ()", , , ...!

+1
0

- - , .

, , , - :

PHP MySQL :

If you are trying to port this to technical attributes, you can see how Magento Commerce does this because their method is good too.

0
source

All Articles