php - E-commerce product filter db design -
i'm creating e-commerce site , products grouped in categories (like in other e-commerce system).
the problem following: different categories (and products in it) need have different attributes (like tv's smart tv or not).
so help me product filtering "theory" (db design) practices follow?
and how can "build" these product category pages automatically (to build automatically filters ex.: in tv category switch smart tv or not , in phones category smart phone or not ).
thanks help!
most ecommerce systems utilize category tree infinite levels.
then when editing product show tree checkboxes , click on checkboxes of categories want assign product to.
for need tables: product, category, , category_has_product. when check boxes these categories should inserted category_has_product product.
then when searching bring together product category_has_product, quite simple.
otherwise if want users able take 1 single category end of tree, want able filter products within parent category , include ones in children take @ stuff this, it's more complex understand maybe find other examples on how implement it:
http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/
the point nested categories end storing final category_id on product table able magic include product in search results of parent categories.
so above cover "how manage products categories".
as links: loop within category tree , print links want , how want.
as additional filters such type of tv (smart or not) either include both within categories tree , forget adding additional fields product form or have more complex solution using attributes:
you have table attributes (id, name) , table attributes_value(id, attribute_id, value) on product form instead of having static checkboxes "this tv smart", loop attributes table, , have attribute named "smart tv", , values "yes, no, maybe, etc", utilize draw dynamic dropdowns.
now if want links attributes, create link category , specific attribute specific value. illustration /category.php?id=2&attribute=1&attribute_value=5
also if want have seo-friendly urls, add together "slug" field both category table , attribute_values table , rewrite urls.
you take @ prestashop, uses or used of things discussed here if grew complex , quite pain in ass might provide useful information.
php mysql activerecord yii e-commerce
No comments:
Post a Comment