Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2007
    Location
    Dayton, Ohio
    Posts
    682
    Plugin Contributions
    0

    Default Mass product weight update

    I have over 400 products in my store. All have a weight of 0.375 for the product weight. I would like all products to have a 0.02 weight. Can I do this in bulk? Maybe PHP? If someone knows how to do this it would save me lots of time.

  2. #2
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Mass product weight update

    Quote Originally Posted by sports guy View Post
    I have over 400 products in my store. All have a weight of 0.375 for the product weight. I would like all products to have a 0.02 weight. Can I do this in bulk? Maybe PHP? If someone knows how to do this it would save me lots of time.
    I think the field is product_weight in the products table, so the below should do what is desired if placed in the install sql patches window of the admin.
    Code:
    update products set product_weight=.02 where product_weight=.375
    Or just leave off the where section at the end if you are sure everything is to be set to 0.02.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,704
    Plugin Contributions
    11

    Default Re: Mass product weight update

    BACKUP, BACKUP, BACKUP
    A little help with colors.
    myZenCartHost.com - Zen Cart Certified, PCI Compatible Hosting by JEANDRET
    Free SSL & Domain with semi-annual and longer hosting. Updating 1.5.2 and Up.

  4. #4
    Join Date
    Apr 2007
    Location
    Dayton, Ohio
    Posts
    682
    Plugin Contributions
    0

    Default Re: Mass product weight update

    The actual weight is set at: 0.0375 and I want to change all to zero.

    I tried both of these:
    Code:
    update products set product_weight=.00 where product_weight=.0375
    update products set products_weight=.00 where products_weight=.0375
    Reason: When I looked in my database (php MyAdmin) the product weight was called: products_weight. Niether one above worked, I got a failed message error in my SQL Query Executor window.

  5. #5
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,704
    Plugin Contributions
    11

    Default Re: Mass product weight update

    When you looked at the database, did each table have a prefix? Was products something like zen_products?
    A little help with colors.
    myZenCartHost.com - Zen Cart Certified, PCI Compatible Hosting by JEANDRET
    Free SSL & Domain with semi-annual and longer hosting. Updating 1.5.2 and Up.

  6. #6
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Mass product weight update

    Quote Originally Posted by sports guy View Post
    The actual weight is set at: 0.0375 and I want to change all to zero.

    I tried both of these:
    Code:
    update products set product_weight=.00 where product_weight=.0375
    update products set products_weight=.00 where products_weight=.0375
    Reason: When I looked in my database (php MyAdmin) the product weight was called: products_weight. Niether one above worked, I got a failed message error in my SQL Query Executor window.
    Quote Originally Posted by dbltoe View Post
    When you looked at the database, did each table have a prefix? Was products something like zen_products?
    As dbltoe is hinting at, try the revised sql that has the field products_weight (extra s that I missed) and use it from the ZC admin install sql patch window as I first suggested. This will eliminate the discussion and search for the infamous DB_PREFIX. At least for now.

    Remember zc addresses the database prefix whereas phpmyadmin doesn't know a thing about it and must be manually added.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Mass product weight update

    Quote Originally Posted by sports guy View Post
    The actual weight is set at: 0.0375 and I want to change all to zero.
    How about:
    Code:
    update products set products_weight = 0 where products_weight >= 0.0375 and products_weight <= 0.0376;
    .

    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.

  8. #8
    Join Date
    Apr 2007
    Location
    Dayton, Ohio
    Posts
    682
    Plugin Contributions
    0

    Default Re: Mass product weight update

    Quote Originally Posted by DrByte View Post
    How about:
    Code:
    update products set products_weight = 0 where products_weight >= 0.0375 and products_weight <= 0.0376;
    That was the ticket, it worked perfectly. All products are now at zero weight. So I suppose I needed to add the semicolon at the end of the command line for one. Plus it seems as if you added spaces after the = sign. Thank you all for your help.

  9. #9
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Mass product weight update

    No, it's neither the spaces nor the semicolon, although those make for better syntax.
    The field is a data-type of "float", and a direct "equals" comparison doesn't always work as an exact match, hence the suggestion of giving it a range of "greater than or equal to 0.0375 AND less than or equal to 0.0376".
    .

    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.

 

 

Similar Threads

  1. Mass update product expected dates via SQL query
    By misaki in forum General Questions
    Replies: 3
    Last Post: 22 May 2010, 01:18 AM
  2. Replies: 5
    Last Post: 16 May 2009, 09:53 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