Results 1 to 3 of 3
  1. #1
    Join Date
    May 2009
    Location
    North Las Vegas, NV
    Posts
    44
    Plugin Contributions
    0

    Default Problem Adding New Option Values

    I just recently encountered a problem when adding a new Option Values (to an Option Name). Here is the error message I receive:

    1062 Duplicate entry '0' for key 1
    in:
    [insert into products_options_values_to_products_options (products_options_id, products_options_values_id) values ('5', '208')]
    If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

    And to answer some of the questions pertinent to any bug report:

    * What version of Zen Cart are you using?
    ANSWER: 1.3.9a

    * Has your site been upgraded? When? From what version(s)?
    ANSWER: No, new install (for testing)

    * What addons have you installed? When?
    ANSWER:
    1 - Recover_Cart_Sales
    2 - Encrypted_Master_Password_1.2
    3 - Stock_by_Attributes
    4 - Dynamic_DropDowns_for_SBA
    5 - Super_Orders_20_rev48
    6 - PDF_Order_Center_v1.2.1

    * In what ways is your site customized or different from a brand new uncustomized install?
    ANSWER: basically just a re-skin (aka templating)

    Here is what I've done to FIX the problem:

    MySQL myPHPadmin FIX #1 (for immediate resolution): I re-ran the SQL Insert with this:

    insert into products_options_values_to_products_options (products_options_values_to_products_options_id, products_options_id, products_options_values_id) values ('208', '5', '208');

    options_values_manager.php FIX #2 (a more permanent fix!):

    // Start FIX: Fix for Inserts when adding new Option Values:
    // Here is the Original code:
    // $db->Execute("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . "
    // (products_options_id, products_options_values_id)
    // values ('" . (int)$option_id . "', '" . (int)$value_id . "')");
    // Here is the Modified Code:
    $db->Execute("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . "
    (products_options_values_to_products_options_id, products_options_id, products_options_values_id)
    values ('" . (int)$value_id . "', '" . (int)$option_id . "', '" . (int)$value_id . "')");
    // End FIX

    COMMENTS: I don't think that the table "products_options_values_to_products_options" has AUTO-INCREMENT set for the field "products_options_values_to_products_options_id". Either AUTO-INCREMENT should be set or the code is modified as suggested above.

    Kind regards,

    Chris Lemke
    (aka Mega Moonshine)

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Problem Adding New Option Values

    Quote Originally Posted by Mega Moonshine View Post
    COMMENTS: I don't think that the table "products_options_values_to_products_options" has AUTO-INCREMENT set for the field "products_options_values_to_products_options_id". Either AUTO-INCREMENT should be set or the code is modified as suggested above.
    Therein lies your problem.
    A fresh clean install *does* have AUTO_INCREMENT set on that field.
    You need to re-instate that, and then it will work correctly as designed.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    May 2009
    Location
    North Las Vegas, NV
    Posts
    44
    Plugin Contributions
    0

    Default Re: Problem Adding New Option Values

    Quote Originally Posted by DrByte View Post
    Therein lies your problem.
    A fresh clean install *does* have AUTO_INCREMENT set on that field.
    You need to re-instate that, and then it will work correctly as designed.
    Thanks for the heads up on the resolution. Wonder how Auto-Increment was turned off? I'm suspecting it may be occurring from installing the Stock by Attributes or the Dynamic Dropdowns for SBA mod...

    I've checked several other test carts and the same thing (no Auto-Increment) is set and all have both of those mods installed.

    Good thing then that I'm writing my own mod that will do the following (as I'm frustrated with the mentioned SBA mods and there is other features sorely missing for easy administration):

    1. Product Option Dependencies by Attributes
    2. Product Images by Attributes
    3. Product Stock by Attributes
    4. Product Suppliers (& Supplier SKU's) by Attributes

    I am handling dependencies from 2 to 4 assigned options to a product and can handle all variations easily and quickly.

    There will be added tools for easily copying data/option sets, image sets, etc. to other products as well. Very handy for those who have garment products such as T-shirts and other types of clothing based on style, color, and sizes.

    The admin backend is nearly complete and functions fully, where you setup all the dependencies, etc. just from reading/pulling options & attribute names/values from the database. I then store the dependencies as an array in a new table.

    My biggest hurdle now is how to integrate the thing into Zen Cart so it can make use of the information! What I'm looking for is where I can, at one central point (a particular .php file? or several?), add the code to where it would allow me to add to the URI stream right after "&product_id=" so I can insert and pass the initial data to get the process started for managing options by dependicies, etc. (Perhaps there is a "zen_does_this()" function I can use or mod to make it happen?)

    Sorry for rambling on. I should post this question I suppose, but which particular area in the forums?

    Thanks!

    Chris Lemke
    (aka Mega Moonshine)

 

 

Similar Threads

  1. Error when adding new option values
    By rdhoke in forum Setting Up Categories, Products, Attributes
    Replies: 9
    Last Post: 28 Dec 2012, 10:21 PM
  2. error adding attribute option values
    By g28469b in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 6 Jul 2010, 12:09 PM
  3. Adding all Option Values within an Option to a product
    By ktomas in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 6 Jul 2009, 03:30 AM
  4. Adding all option values?
    By lionrhod in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 29 Dec 2006, 05:44 AM

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