Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    Dec 2012
    Posts
    607
    Plugin Contributions
    0

    Default Change Product Model Numbers en masse?

    What is the best way to mass replace existing products_models without changing products_ids; for a given manufctuer?

    By mistake products_models are entered as numeric. Leaving out the manufacturers abbreviation, in-front of the model number.

    Need to change from 123456 to GHD-123456.

    What is the best way to do this, other than one by one through PHPMyAdmin?
    Using Zen Cart 1.5.1

  2. #2
    Join Date
    May 2013
    Posts
    38
    Plugin Contributions
    0

    Default Re: Change Product Model Numbers en masse?

    Back up your database first because bad things happen accidentally.

    Code:
    UPDATE products SET products_model = CONCAT("GHD-",products_model);
    This will update every product to have its model number prepended with "GHD-".

  3. #3
    Join Date
    Dec 2012
    Posts
    607
    Plugin Contributions
    0

    Default Re: Change Product Model Numbers en masse?

    Thank you for the reply.

    How would you limit this concatenation to a specific manufacturers_id from zen_manufacturers table?
    Using Zen Cart 1.5.1

  4. #4
    Join Date
    May 2013
    Posts
    38
    Plugin Contributions
    0

    Default Re: Change Product Model Numbers en masse?

    Let's say the manufacturer_id you wanted to work with was 1. Here's what the query would look like:

    Code:
    UPDATE products SET products_model = CONCAT("GHD-",products_model) WHERE manufacturers_id = 1;
    If you wanted to do this by name, you could, but it would require some joins.

  5. #5
    Join Date
    Feb 2011
    Location
    Lumberton, TX
    Posts
    527
    Plugin Contributions
    0

    Default Re: Change Product Model Numbers en masse?

    Quote Originally Posted by allthingsidLeroy View Post
    Let's say the manufacturer_id you wanted to work with was 1. Here's what the query would look like:

    Code:
    UPDATE products SET products_model = CONCAT("GHD-",products_model) WHERE manufacturers_id = 1;
    If you wanted to do this by name, you could, but it would require some joins.
    If this is for a small number of manufacturers I would use the above as its simple and clean. However, if you are not familiar with SQL statements for modifying the database...be very careful...in fact..if that is the case, post what you want to change and let one of the experts give you the SQL statement to run as a mistake could be costly...BACKUP....BACKUP....BACKUP lol.

  6. #6
    Join Date
    Dec 2012
    Posts
    607
    Plugin Contributions
    0

    Default Re: Change Product Model Numbers en masse?

    Quote Originally Posted by g2ktcf View Post
    If this is for a small number of manufacturers I would use the above as its simple and clean. However, if you are not familiar with SQL statements for modifying the database...be very careful...in fact..if that is the case, post what you want to change and let one of the experts give you the SQL statement to run as a mistake could be costly...BACKUP....BACKUP....BACKUP lol.
    Thank you for the advice. Don't know much about SQL statements.

    My case is exactly as I stated.

    I need to change / revise existing products_models without changing products_ids; for a defined manufacturer in the cart.

    ie. Need to change products_models from 123456 to GHD-123456, for XYZ manufacturer (XYZ manufacturers_id is 5)

    What is the SQL statement for the above?
    Is it not the following:
    Code:
    UPDATE products SET products_model = CONCAT("GHD-",products_model) WHERE manufacturers_id = 5;
    Using Zen Cart 1.5.1

  7. #7
    Join Date
    Feb 2011
    Location
    Lumberton, TX
    Posts
    527
    Plugin Contributions
    0

    Default Re: Change Product Model Numbers en masse?

    Quote Originally Posted by Kevin205 View Post
    Thank you for the advice. Don't know much about SQL statements.

    My case is exactly as I stated.

    I need to change / revise existing products_models without changing products_ids; for a defined manufacturer in the cart.

    ie. Need to change products_models from 123456 to GHD-123456, for XYZ manufacturer (XYZ manufacturers_id is 5)

    What is the SQL statement for the above?
    Is it not the following:
    Code:
    UPDATE products SET products_model = CONCAT("GHD-",products_model) WHERE manufacturers_id = 5;
    do you have a DB_PREFIX? All of my tables have zen_ in front of them.....

    if not, then the code above appears correct...BUT I AM NOT AN EXPERT BY ANY MEANS

  8. #8
    Join Date
    May 2013
    Posts
    38
    Plugin Contributions
    0

    Default Re: Change Product Model Numbers en masse?

    Quote Originally Posted by Kevin205 View Post
    Is it not the following:
    Code:
    UPDATE products SET products_model = CONCAT("GHD-",products_model) WHERE manufacturers_id = 5;
    That looks right to me.

    Quote Originally Posted by g2ktcf View Post
    do you have a DB_PREFIX? All of my tables have zen_ in front of them.....

    if not, then the code above appears correct...BUT I AM NOT AN EXPERT BY ANY MEANS
    I forgot about this. But in PHPmyAdmin usually there's a place where you can 'use' a database. In any case, if you do have a prefix, you can just use that. This query isn't exactly all that complex.
    Last edited by allthingsidLeroy; 25 Jun 2013 at 04:24 PM.

  9. #9
    Join Date
    Dec 2012
    Posts
    607
    Plugin Contributions
    0

    Default Re: Change Product Model Numbers en masse?

    Quote Originally Posted by allthingsidLeroy View Post
    That looks right to me.



    I forgot about this. But in PHPmyAdmin usually there's a place where you can 'use' a database. In any case, if you do have a prefix, you can just use that. This query isn't exactly all that complex.
    All of my cart tables have zen_ prefix in SQL. So it would be:
    Code:
    UPDATE zen_products SET products_model = CONCAT("GHD-",products_model) WHERE manufacturers_id = 5;

    This should be executed from PHPMyAdmin. Correct?
    Last edited by Kevin205; 25 Jun 2013 at 04:48 PM.
    Using Zen Cart 1.5.1

  10. #10
    Join Date
    Feb 2011
    Location
    Lumberton, TX
    Posts
    527
    Plugin Contributions
    0

    Default Re: Change Product Model Numbers en masse?

    Quote Originally Posted by Kevin205 View Post
    All of my cart's tables have zen_ prefix in SQL. But in the following statement there is no mention of any table(s)!
    Code:
    UPDATE products SET products_model = CONCAT("GHD-",products_model) WHERE manufacturers_id = 5;
    Why should the zen_ prefix matter?


    Should this be executed from cart's admin or form PHPMyAdmin?
    if you run this from phpMyAdmin...and you have a prefix...then the code will error out. I am not sure about running it from the cart's admin as I do not use that very frequently.

    **ALSO...if you do this...put your store in maintenance mode just in case....oh I did say backup your database right?**

    If your database is backed up...you can simply restore it if the statement does something unexpected.
    Last edited by g2ktcf; 25 Jun 2013 at 04:53 PM.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Auto Increment Product Model Numbers?
    By jaqdaw in forum General Questions
    Replies: 0
    Last Post: 8 Feb 2011, 06:06 PM
  2. Trying to change/add model numbers with EZPopulate
    By fredsjo in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 25 Jul 2010, 09:36 AM
  3. Model Numbers With Product Options
    By DiZZ in forum General Questions
    Replies: 8
    Last Post: 17 Nov 2006, 04:16 PM
  4. Attribute product model numbers
    By Muddler in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 17 Oct 2006, 11:10 PM

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