Definition of dependent attributes
Example: A dress has two attributes, the color and size
Color: blue, red, purple
Size: S, M, L, XL
There are 12 option combinations including ‘Blue S’, ‘blue M,’…. ‘purple XL’ etc.
In reality, some combinations are not available, such as when the ‘purple XL’ is out of stock.
So there is a requirement like this, When the ‘purple’ is selected, the option of ‘XL’ becomes disabled. And When the ‘XL’ is selected, the option of ‘purple’ becomes disabled.
We call this ‘rule of dependent attribute’ or ‘rules’ as abbreviation below.
Below is an image to illustrate this requirement.
Features of rule of dependent attribute for apparel products
1: Each product has its own rule of dependent attributes, i.e, the rule of dependent attributes is product-specific.
2: The rule of dependent attributes is created in an ERP warehouse system. And the rule of dependent attributes changes on the daily basis.
Solutions to realize rule of dependent attributes in Zen cart
Obviously Zen cart itself has no such function. There are two methods to realize it.
Solution 1: Add a new table to store the ‘rules’ and load the ‘rules’ when product is displayed.
This is very complicated, much programming work needed.
Solution 2: Use the javascript to realize the ‘rules’ ,and add the javascript to Product description field.
This is quite easy to do, an typical javascript is shown below.
New issue and my questions
But there is an efficiency issue for solution 2. As I have said ‘the rule of dependent attributes changes on the daily basis’, which results a daily update work on all products’ Description field where the javascript to realize ‘rules’ is stored. That would affect the online store very much.
I am thinking about using a new field rather than product Description field to store the javascript of ‘rules’, in that case, only this new field is frequently updated rather than the product Description field.
There are also two possible solutions when thinking using a new field to store javascript.
1: add a new field to Product_Description table.
Or
2: use a existing field in Product_Description table.
The only possible field is product_url field. First change it to Text type from VarChar type.
Therefore here are my questions
Which solution do you recommend? What are the advantages and disadvantages of them?
If add a new field to Product_Description table, how to acquire its value at tpl_product_display.php?
Is there a potential risk to add a new field to Product_Description?
Thank you so much in advance.
Bookmarks