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![]()
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![]()
You could just use a quick UPDATE in the Tools ... Install SQL Patches ...
That will change ALL products_model to match the products_id of ALL of your Products ...Code:UPDATE products SET products_model= products_id;
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!
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?
![]()
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:
change to read:Code://///////////////////////////////////////////////////// //// INSERT PRODUCT-TYPE-SPECIFIC *INSERTS* HERE //////
This will add the new products_id as the products_model when adding new products ...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 //////
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!
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!![]()
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!
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!![]()