Quick Tip - Delete Your Options - Yes Really!

Anyone who has imported options on mass will know once you have them in and with stock tracking enabled it’s a bit of a pain to change them (on mass that is). Even if you change them one at a time you need to “rebuild” them. And if like me you have 2000 products setup with options stock tracking and then change your mind and want them all without options what do you do ?



Well you can either spend the rest of you life changing them one at a time or you can use this ugly way I’m going to show you now. Importing new options simple adds another option also.



Here I’ll delete all the options for a full category.


  1. You’ll need the product ID of every product. The simple way to get this is to go into a category list all the products and choose export to get them in a csv file.


  2. Now we need the url cs-cart uses to delete an option from a product. So go into one of the products with the option you want to remove and click options. Then hover your pointer of status - DELETE and right-click selecting copy shortcut.


  3. Copy this shortcut into a spreadsheet, it should look a bit like this;



    YOURSITE/admin.php?dispatch=product_options.delete&option_id=[color=#ff0000]14[/color]&product_id=[color=#ff0000]2503[/color]



    14 = the option ID

    2503 = the product Id


  4. Remove the product id from the end after pasting the shortcut in the spreadsheet. Open your exported product csv file and copy all the product ids (normally the last coloumn). Now copy that into the next column after the already copied shortcut in the shortcut spreadsheet.


  5. Then copy all the data into a text editor, use search and replace to remove the space left between the “&prduct_id=” and “somenumber” - Now you have a complete list of all the urls needed to delete all the options from all the products.


  6. All you have to do is open each on in the browser. To do that I used http://www.urlopener.com - copy your list in the box and hit submit. Hit submit again to open each url. A new tab will open for each url so be warned that your browser may stop responding if you do too many. I was in a hurry and so did 2000 :-) took about 30 minuites with a few “this script has stopped responding” - keep running.



    I’m sure some cleaver bod could do a addon for this or a better script that closes the tab each time. But till then I hope this helps some one, I’ve also used this meathod to rebuild options.

Nice one ! thx.





John

You could achieve the same result in less than 5 seconds using SQL…? Might save you a lot of 30 minutes and headache time.

[quote name='StellarBytes' timestamp='1363895593' post='158417']

You could achieve the same result in less than 5 seconds using SQL…? Might save you a lot of 30 minutes and headache time.

[/quote]



Yep I know, but I tend to not want to run them on live sites.

CS-Cart is still executing SQL statements the long road for a shortcut on these live stores?

[quote name=‘StellarBytes’ timestamp=‘1363896850’ post=‘158426’]

CS-Cart is still executing SQL statements the long road for a shortcut on these live stores?

[/quote]



It is but it’s not me entering the SQL and making a mistake that deletes the whole stock list :-)

This was just the tip i was looking for, but what about the option_id, do these need to be changed also?



Your quick tip doesn't seem to mention it.

If you copy the url on your site no the ID shouldn't need changing but also bear in mind if you have your Tracking set to “O” (with options) you'll also need to change that. This can be done simply by exporting the minimum product fields including tracking. Change the value to “B” for tracking without options.

Just trying this on 4.3.6 and get page 404 even if I just copy and paste from the delete button in admin, to browser...Im sure it has something to do with the popup that says "are you sure you want to proceed" any work round?

John

** Update, CS say this no longer works in later versions...