Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2010
    Posts
    143
    Plugin Contributions
    0

    Default my solution of dependent attributes & need help from you

    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.

    Click image for larger version. 

Name:	dependentAttr.jpg 
Views:	87 
Size:	24.3 KB 
ID:	11513





    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.

    Click image for larger version. 

Name:	javascript.jpg 
Views:	78 
Size:	57.4 KB 
ID:	11512


    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.







    Last edited by mybiz9999; 24 Nov 2012 at 07:46 AM.

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: my solution of dependent attributes & need help from you

    Repurposing an existing field will obviously disable it for its original use, so would not be a good general-purpose approach. It would work fine for a single store that will never use the particular field. I recommend creating a new field, as that will be suitable for all stores, and there are a lot that will want to use this feature if it is developed and released.

    I think a field that holds an array of relationship values (pairs of attribute ids and the kind of dependency between them) rather than specific js code would be more maintainable. You would then put the script in a jscript_attributes.js file placed to load on product info pages, and grab whatever relationship parameters are present and apply them.

    There is at least one mod in Plugins for creating new product fields and using them, which you could use as a guide for that part.

 

 

Similar Threads

  1. Dependent Attributes
    By draude in forum Setting Up Categories, Products, Attributes
    Replies: 61
    Last Post: 25 Oct 2021, 03:32 AM
  2. Layout of Attributes - need help & suggestions
    By GoldBuckle in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 20 Oct 2009, 04:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR