[SMS] SQL-Query to get all products in one category?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
zappodrom
Forum Members
Forum Members
Posts: 91
Joined: Wed Apr 23, 2008 11:38 am
Location: Germany

[SMS] SQL-Query to get all products in one category?

Post 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
Regards,
Christian

----
[X] <--- Nail here for new Monitor!
Peciura

Re: [SMS] SQL-Query to get all products in one category?

Post 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.
Last edited by Peciura on Sat Sep 25, 2010 11:24 am, edited 1 time in total.
User avatar
zappodrom
Forum Members
Forum Members
Posts: 91
Joined: Wed Apr 23, 2008 11:38 am
Location: Germany

Re: [SMS] SQL-Query to get all products in one category?

Post by zappodrom »

Thank you, that's really cool!  ;D

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....
Regards,
Christian

----
[X] <--- Nail here for new Monitor!
Post Reply

Return to “Modules/Add-Ons”