With regard to comments and reviews...
I have a large number of products imported into my store. The comments and reviews are not automatically active and I have to set each product to allow reviews. I am using the following code:
// get all the active product_id's from the cscart_products table
$query = "SELECT product_id FROM cscart_products WHERE status='A'";
$productsResult = mysql_query($query);
$numRows = mysql_numrows($productsResult);
echo "Processing $numRows product id's...\n";
while ($row = mysql_fetch_assoc($productsResult)) {
$cscart_product_id = $row['product_id'];
// see if there is a row already for this cscart_product_id
$query="select object_id from cscart_discussion where object_id=$cscart_product_id AND object_type = 'P'";
$result=mysql_query($query);
// if not, add a row to cscart_discussion
if (mysql_num_rows($result) == 0) {
echo "Inserting record into cscart_discussion for $cscart_product_id\n";
$query="INSERT INTO cscart_discussion (object_id, object_type, type) VALUES ($cscart_product_id, 'P', 'B')";
$result=mysql_query($query);
if (!$result)
echo "Query failed: ($query): " . mysql_error(). "\n";
}
}
echo "All Done";
?>
This code worked fine in my old V2.x.x cart, but in V4 there is an additional field called "company_id". This field is defaulting to '0' and I need it to default or change to '1'.
I changed the $query to:
$query="INSERT INTO cscart_discussion (object_id, object_type, type, company_id) VALUES ($cscart_product_id, 'P', 'B', '1')";
But this only updates new rows. How do I change existing rows company_id from '0' to '1'?
Thanks in advance for any help you may provide.