Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2008
    Location
    Athens
    Posts
    84
    Plugin Contributions
    0

    Default Using products_id as Products Model

    Hello Zeners!

    I want my products getting as Products Model the products_id that zencart automatically generate.

    Is a simple way to do that?

    Kind regards

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Using products_id as Products Model

    You could just use a quick UPDATE in the Tools ... Install SQL Patches ...
    Code:
    UPDATE products SET products_model= products_id;
    That will change ALL products_model to match the products_id of ALL of your Products ...

    NOTE: Backing up your database before doing something like this is always a good idea ...

    You could also customize the code to do this when new Products are added to the database if you get tired of running the code manually ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Apr 2008
    Location
    Athens
    Posts
    84
    Plugin Contributions
    0

    Default Re: Using products_id as Products Model

    Thanks Ajeh!

    Please tell me in which file I must add this sql statement so do this automatically every time I add a new product?


  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Using products_id as Products Model

    The SQL statement is just for a quick, global change of all products_model to match the products_id ...

    To customize the code to do this when adding a New Product, you would need to customize the file:
    /admin/includes/modules/update_products.php

    NOTE: and you would need to customize any other product type with its own update module ...

    and around line 86 you will see:
    Code:
          ///////////////////////////////////////////////////////
          //// INSERT PRODUCT-TYPE-SPECIFIC *INSERTS* HERE //////
    change to read:
    Code:
    // update products_model with products_id
          $sql_data_array = array( 'products_model' => (int)$products_id);
          zen_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");
    
          ///////////////////////////////////////////////////////
          //// INSERT PRODUCT-TYPE-SPECIFIC *INSERTS* HERE //////
    This will add the new products_id as the products_model when adding new products ...

    NOTE: even if you enter a products_model manually when adding a Product, this will override that ...

    If you needed a different products_model you should be able to still edit the Product to change this manually ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Apr 2008
    Location
    Athens
    Posts
    84
    Plugin Contributions
    0

    Default Re: Using products_id as Products Model

    Thanx Ajeh it worked on new products but not worked when I copy(duplicate) similar products changing the desctription a bit and then hit update.
    Can this function works automatically when copying(duplicating) similar products?

    Thanx again for your help!

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Using products_id as Products Model

    I would have to customize the code in a number of places to manage everything that you need for this to work everywhere in relationship to maintaining the products_id and products_model match ...

    You might try a search in the Admin using the Developers Tool Kit for:
    products_model

    and see if you can spot all of the places that this code might need to be changed ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  7. #7
    Join Date
    Apr 2008
    Location
    Athens
    Posts
    84
    Plugin Contributions
    0

    Default Re: Using products_id as Products Model

    Ok I found it!

    In admin/includes/modules/copy_to_confirm.php

    In about line 110
    //FIX here

    added the previous statement

    Code:
    // update products_model with products_id
          $sql_data_array = array( 'products_model' => (int)$products_id);
          zen_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");

    and works also when I copy (duplicate) products!

    Thanks again for your help!

 

 

Similar Threads

  1. v151 Custom Field or using Product Model
    By jen2swt in forum Customization from the Admin
    Replies: 1
    Last Post: 14 Feb 2014, 03:24 PM
  2. Replies: 1
    Last Post: 24 Jan 2012, 09:10 AM
  3. 1264 Out of range value for column 'products_id' at row 1 - after importing products
    By suntower in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 20 Nov 2010, 12:23 AM
  4. Using a Smart Numbering System in lieu of the default products_id
    By dmfelder in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 13 Dec 2006, 07:08 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