Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

deleting all products but not Categories. Rate Topic   - - - - -

 
  • BaDTaG
  • Senior Member
  • Members
  • Join Date: 01-Jul 11
  • 188 posts

Posted 06 February 2013 - 09:40 PM #1

Hi you all.

how can i delete all products but not my categories?

it seams to me that it is not optimal i have to delete my categories.

is there a way around this? i have about 52k and it will take to long to delete 500 at a time. so if there is a quick way pleas lat me know
VPS Hosting whit easy VPS control panel no technical skills required.
EDB Eksperten din online it forhandler

 
  • StellarBytes
  • Senior Member
  • Members
  • Join Date: 08-Aug 11
  • 1807 posts

Posted 06 February 2013 - 11:38 PM #2

With that many products to delete, I'd just delete all the product related data from the database. Or you could set the products page in admin to display 1000 at a time and try delete them all that way, still it's going to take a while doing that 52 times and waiting for the page to load with 1000 products on it each time.
Hire StellarBytes for CS-Cart Design & Development Services

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1242 posts

Posted 07 February 2013 - 08:00 AM #3

You can delete all products by adding
<?php
/*****************************************************************
*															    *
*   (c) 2013 HungryWeb.net | Support at Yum [at] hungryweb.net   *
*															    *
*****************************************************************/

if ( !defined('AREA') ) { die('Access denied'); }

if($mode=='delete_all_products'){
    $products = db_get_array('SELECT product_id FROM ?:products');
    foreach($products as $p){
        fn_delete_product($p['product_id']);
    }
    
    fn_set_notification('N', fn_get_lang_var('notice'), 'All the products has been deleted with succes!');
    return array(CONTROLLER_STATUS_OK, "products.manage");
}
?>
into /addons/my_changes/controllers/admin/my_changes.php, if the folders or file are missing you need to create them.

After adding the code in the right place you just need to access the link http://www.your_doma...te_all_products

If you rename admin.php you replace with your own, link can be accessed only from admin.

My Advice: After you delete the products please add this secure code exit;
...
if($mode=='delete_all_products'){
exit;
...
for you not to be able to delete products by mistake in the future, and when you wish to delete them again just comment the exit like this
...
if($mode=='delete_all_products'){
//exit;
...
and access the link above.


I hope that helps,

---
Valentin

 
  • BaDTaG
  • Senior Member
  • Members
  • Join Date: 01-Jul 11
  • 188 posts

Posted 07 February 2013 - 11:29 AM #4

Hi just to be shure is it /addons/my_changes/controllers/admin/my_changes.php or skin/myskin/admin/addons/my_changes/controllers/admin/my_changes.php

I cant accualy test it before i am reday to delete all :o)

Thanks m8
VPS Hosting whit easy VPS control panel no technical skills required.
EDB Eksperten din online it forhandler

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1242 posts

Posted 07 February 2013 - 01:09 PM #5

This is not a skin file ;) , the address is correct.
How do you wish to test it ? :D

---
Valentin

 
  • BaDTaG
  • Senior Member
  • Members
  • Join Date: 01-Jul 11
  • 188 posts

Posted 07 February 2013 - 01:27 PM #6

Thanks then i dit it the right way :grin:

but i added the exit option and i get error 404 page not found. i will test it this weekend or maby ill set up a test server and test it there first.


thanks again m8
VPS Hosting whit easy VPS control panel no technical skills required.
EDB Eksperten din online it forhandler

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1242 posts

Posted 07 February 2013 - 04:10 PM #7

enjoy

 

Posted 20 February 2013 - 07:02 AM #8

This was a VERY helful piece of code. Thanks Vali. Worked for me on cscart Ultimate.

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1242 posts

Posted 20 February 2013 - 07:20 AM #9

@swimcommunications
Glad to hear it

---
Valentin

 
  • jmarshall
  • Newbie
  • Members
  • Join Date: 21-Aug 12
  • 14 posts

Posted 22 February 2013 - 04:54 PM #10

When running this option to delete products will it also delete all the product images? We have had issues in the past trying to delete products to do a re-import and the old images were still on the FTP server in folders under product images. Then when re-importing products products would have the wrong images almost as if part of the database thought there shouldn't be any product images but then the component importing the images was logging the new images as product image # 587 rather than #1. Basically we are wanting a way to clear out all products, and then clear out all product images, both from the database and the FTP server, and get the cart products and associated images back to as if we cleared out everything and started from scratch. Any help is appreciated
Bluefoot Technology
http://www.bluefoot.com

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1242 posts

Posted 22 February 2013 - 06:53 PM #11

@jmarshall
fn_delete_product($product_id) is function used by cs-cart to delete a product, it's deleting anything is related to the product (images, features, options ... ) and hooks related to this action used into any custom addon

---
Valentin

 

Posted 26 May 2014 - 08:55 PM #12

You can delete all products by adding

<?php
/*****************************************************************
*																*
*   (c) 2013 HungryWeb.net | Support at Yum [at] hungryweb.net   *
*																*
*****************************************************************/

if ( !defined('AREA') ) { die('Access denied'); }

if($mode=='delete_all_products'){
	$products = db_get_array('SELECT product_id FROM ?:products');
	foreach($products as $p){
		fn_delete_product($p['product_id']);
	}
	
	fn_set_notification('N', fn_get_lang_var('notice'), 'All the products has been deleted with succes!');
	return array(CONTROLLER_STATUS_OK, "products.manage");
}
?>
into /addons/my_changes/controllers/admin/my_changes.php, if the folders or file are missing you need to create them.

After adding the code in the right place you just need to access the link http://www.your_doma...te_all_products

If you rename admin.php you replace with your own, link can be accessed only from admin.

My Advice: After you delete the products please add this secure code exit;
...
if($mode=='delete_all_products'){
exit;
...
for you not to be able to delete products by mistake in the future, and when you wish to delete them again just comment the exit like this
...
if($mode=='delete_all_products'){
//exit;
...
and access the link above.


I hope that helps,

---
Valentin


Hello how can i adapt it in cs-cart 4.1.4 , i want to use a csv file to delete some products, around 200 products

 
  • pholcomb
  • Junior Member
  • Members
  • Join Date: 27-May 10
  • 9 posts

Posted 04 August 2014 - 06:49 PM #13

You can delete all products by adding

<?php
/*****************************************************************
*																*
*   (c) 2013 HungryWeb.net | Support at Yum [at] hungryweb.net   *
*																*
*****************************************************************/

if ( !defined('AREA') ) { die('Access denied'); }

if($mode=='delete_all_products'){
	$products = db_get_array('SELECT product_id FROM ?:products');
	foreach($products as $p){
		fn_delete_product($p['product_id']);
	}
	
	fn_set_notification('N', fn_get_lang_var('notice'), 'All the products has been deleted with succes!');
	return array(CONTROLLER_STATUS_OK, "products.manage");
}
?>
into /addons/my_changes/controllers/admin/my_changes.php, if the folders or file are missing you need to create them.

After adding the code in the right place you just need to access the link http://www.your_doma...te_all_products

If you rename admin.php you replace with your own, link can be accessed only from admin.

My Advice: After you delete the products please add this secure code exit;
...
if($mode=='delete_all_products'){
exit;
...
for you not to be able to delete products by mistake in the future, and when you wish to delete them again just comment the exit like this
...
if($mode=='delete_all_products'){
//exit;
...
and access the link above.


I hope that helps,

---
Valentin


What version of CS-Cart does this work for? I have 4.1.5 and I did as you said (created a file at /app/addons/my_changes/controllers/admin/my_changes.php) but nothing happens and I get a 404 error.

 
  • richardfmm
  • Senior Member
  • Trial users
  • Join Date: 20-Apr 12
  • 240 posts

Posted 20 August 2014 - 07:36 PM #14

Hi, is this also working for 4.2.1? thx.

 
  • richardfmm
  • Senior Member
  • Trial users
  • Join Date: 20-Apr 12
  • 240 posts

Posted 20 August 2014 - 07:40 PM #15

Hi, Is this posible to set this link in de admin product_view as extra item? gr.

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1242 posts

Posted 21 August 2014 - 11:01 AM #16

What version of CS-Cart does this work for? I have 4.1.5 and I did as you said (created a file at /app/addons/my_changes/controllers/admin/my_changes.php) but nothing happens and I get a 404 error.


Please check if My Changes add-on is active ;)

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 18798 posts

Posted 21 August 2014 - 11:09 AM #17

What version of CS-Cart does this work for? I have 4.1.5 and I did as you said (created a file at /app/addons/my_changes/controllers/admin/my_changes.php) but nothing happens and I get a 404 error.


Correct path is app/addons/my_changes/controllers/backend/my_changes.php

Please try

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • richardfmm
  • Senior Member
  • Trial users
  • Join Date: 20-Apr 12
  • 240 posts

Posted 21 August 2014 - 01:03 PM #18

Hi,
I have change the dir. to backend and delete the admin dir. butt still not work(404).
Is it posible to make this a item in popdown_selection products?

gr.file:///C:/Users/Richard%20I7/Desktop/delete_products_only.jpg

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 18798 posts

Posted 21 August 2014 - 01:38 PM #19

Hi,
I have change the dir. to backend and delete the admin dir. butt still not work(404).
Is it posible to make this a item in popdown_selection products?

gr.file:///C:/Users/Richard%20I7/Desktop/delete_products_only.jpg


Hm... It works for me. Make sure that the My changes add-on in installed and activated.

Please also attach the image again

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • richardfmm
  • Senior Member
  • Trial users
  • Join Date: 20-Apr 12
  • 240 posts

Posted 21 August 2014 - 02:14 PM #20

Hi,
i have try this: www.domain/public_html/cs4/admin.php?dispatch=my_changes.delete_all_products
and www.domain/public_html/cs4/app/addons/my_changes/controlers/backend/my_changes.php

Bott i get a 404.