Page 1 of 1
[SMS] SQL-Query to get all products in one category?
Posted: Fri Sep 24, 2010 2:24 pm
by zappodrom
Hi out there,
is it possible to switch all products to one category with one SQL-Query? In this case I want all products in the category "root".
Hope someone could help...
Regards,
Zappodrom
Re: [SMS] SQL-Query to get all products in one category?
Posted: Sat Sep 25, 2010 10:50 am
by Peciura
In case of failure do SQL backup first.
Create UDT
$cat_id = 0; // root category id
$return = 'All products assigned to root category';
$gCms = cmsms(); //global $gCms;
$db=&$gCms->GetDB();
$query = 'UPDATE '.cms_db_prefix().'module_sms_product_category SET `category_id` = ?';
if($db->Execute($query, array($cat_id))){
echo $return;
}
else{
echo 'Error in : '.($db->sql);
}
Execute UDT and all products should be assigned to root category.
Edit: fixed typo in UDT.
Re: [SMS] SQL-Query to get all products in one category?
Posted: Sat Sep 25, 2010 11:10 am
by zappodrom
Thank you, that's really cool!
Just corrected the typo
Peciura wrote:
$return = 'All products assigned to root category
to
$return = 'All products assigned to root category';
and everything went fine!
Great....