Forums / General Questions / Mass product weight update

Mass product weight update

Views: 1,035

Results 1 to 9 of 9
24 Jan 2015, 11:16 PM
#1
sports_guy avatar

sports_guy

Totally Zenned

Join Date:
Apr 2007
Location:
Dayton, Ohio
Posts:
682
Plugin Contributions:
0

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.

Building a better web, one site at a time: Dayton Web Design

24 Jan 2015, 11:25 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Mass product weight update

sports guy:

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.

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...

25 Jan 2015, 6:33 AM
#3
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,864
Plugin Contributions:
18

Re: Mass product weight update

BACKUP, BACKUP, BACKUP:yes:

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

25 Jan 2015, 2:21 PM
#4
sports_guy avatar

sports_guy

Totally Zenned

Join Date:
Apr 2007
Location:
Dayton, Ohio
Posts:
682
Plugin Contributions:
0

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:

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.

Building a better web, one site at a time: Dayton Web Design

25 Jan 2015, 3:59 PM
#5
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,864
Plugin Contributions:
18

Re: Mass product weight update

When you looked at the database, did each table have a prefix? Was products something like zen_products?

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

25 Jan 2015, 4:10 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Mass product weight update

sports guy:

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

I tried both of these:

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.

> **dbltoe:**
>
> 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...

25 Jan 2015, 7:43 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Mass product weight update

sports guy:

The actual weight is set at: 0.0375 and I want to change all to zero.
How about: ```
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.

25 Jan 2015, 8:47 PM
#8
sports_guy avatar

sports_guy

Totally Zenned

Join Date:
Apr 2007
Location:
Dayton, Ohio
Posts:
682
Plugin Contributions:
0

Re: Mass product weight update

DrByte:

How about: ```
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.

Building a better web, one site at a time: Dayton Web Design

25 Jan 2015, 8:52 PM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

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.