开发者

Automating Products (with details) Addition

Assume a simple order processing system. A Categor开发者_运维问答y is selected, which lists range of products, and when a product is selected, it allows for details about that product to be entered. The details differ for each product.

The admin user wants enable adding new products to this system, without the programmer getting involved. The challenging part is the details form is different for each product.

Consider the following work flow:

Add Service -> Add Genera Properties (Description, Price, BillType, AveActivationTime) -> Add Specific Properties (FieldName, ValueType, MandatorOrNot).

Currently, the system has a pop up for each product. But that has be desiged by a programmer. It seems the form generation has to be automatized. What is a good approach to dealing with this issue?


Perhaps have a customfields table, with the following fields:

id (auto increment?)
itemType (link to type of item that uses these fields)
name
type
options
default
required

Then, when you display the update form you can loop through all the custom fields attached to the current itemType. If the field is a string, display a string input; if it's an option, display a select box etc.

Then store the actual values in a customdata table:

id
itemID
fieldID
value

You may want to extend this to allow, for example, sharing custom fields across different itemTypes.

Have you looked at existing e-commerce solutions? I would think most of them have this functionality built in. No point in reinventing the wheel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜