Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How do you add weight to a whole category?


fettah666

Recommended Posts

Posted

My friend was filing the catalogue while I was away and simply forgot to add weight to the products so my question is very simple: can you add weight to a whole category? We have several categories but I have no idea how to correct his mistake.

 

Sorta related but less important, how do you add a date to a whole category? He forgot that too!

 

Yeah, I know, gotta change my friends...

Posted

you could You could write some sql to set all the wts in a category to the same wt

 

or

 

install a contribution called EasyPopulate and use that

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Posted

Unfortunately, we didn't have any files to use along easy populate so that's outta question and well, let's say my sql knowledge is close to zero (actually, it's IS nil) so I have no way to write such thing.

Posted

Install EP download a file which will contain all your current products.

 

Edit the file and add the wts.

 

Import the file

 

or go to www.w3schools.com

 

You will need something along the linews of...

 

update product set product_wt = 1.0 where product_caegory_id = 17

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Posted

Try the following:

 

Edit the $category, $weight, $date as required .. then ..

Save it as a file in shop root (cat_update.php or something) then browse to the file, it will show a list of queries that it WOULD run.

 

If you are happy with those queries then edit the file and set $testrun = false; run it again and the queries will be actioned.

 

<?php
require_once 'includes/application_top.php';

// User settings
$testrun = true;
$category = 10;
$weight = 1.0;
$date = '2009-04-11 00:00:00'; // date("d-m-Y h:i:s")
// End user settings
$sql = "
SELECT products_id FROM " . TABLE_PRODUCTS_TO_CATEGORIES . "
WHERE categories_id = $category";
$result = tep_db_query($sql);

while ( $row = tep_db_fetch_array($result) ){
 if ( false !== $testrun ){
echo "UPDATE " . TABLE_PRODUCTS . " SET products_weight = '" . (float)$weight . "', products_date_available = '" . $date . "' WHERE products_id = " . $row['products_id'] . "" . '<br>';
 } else {
$sql = "UPDATE " . TABLE_PRODUCTS . " SET products_weight = '" . (float)$weight . "', products_date_available = '" . $date . "' WHERE products_id = " . (int)$row['products_id'] . "";
tep_db_query($sql);
 }
}
tep_db_free_result($result);  
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...