Hi,
I'm currently building an e-commerce website using Laravel but I can't seem to figure out a nice way to store products in the database. The main problem I'm having is when a product can have different size options. I don't want to person on the back end have to enter the same product description and images etc for each size product that they add.
Any help is greatly appreciated. Thanks
If the product with different size/color options are different SKU, they deserve the description and images, in which case just write a simple utility for backend guy to copy it from an existing product.
Or/And, make your product table abstract with only fields which will not change, put all other fields such as size/color/price etc ... in a pivot table, backend guy then simply add these attributes to pivot table.
I'm creating a similar website. I was thinking about an "options" field in the database that is json. If a custom field is added to the product (dropdown etc) then it's stored in the json and I can pull it later.
@Jaytee That's a possible solution but I'd rather not store JSON in the database, think I'll have to make a 'products' table that contains description and images, then a 'product_sizes' table that contains different size options, price and sku and see how that goes :)
@d3xt3r@ohffs@matt_penton Sorry for hijacking the thread, but how would i approach this? I didn't want to create new fields in my table like:
size,
color
etc
As there will be many different options for each product such as a dropdown or select box thus I thought json would be the best approach just to remove unwanted fields from my table if multiple products don't share that feature.
Don't forget, some products may have different size only, some different color only, some have different size and different color, and each of these products can have a different price.. and of course, some products have no variations :)
I've built a few e-commerce sites in old-style PHP many years ago, it was fun :)