Page 1 of 4

[1.4.x][MOD] - Remove All Demo Data

Posted: Mon Apr 12, 2010 10:56 am
by Qphoria
For those who do a fresh install but don't want to have to clean up all the DEMO data..

Right after install, execute this sql in your phpmyadmin sql window. Change "oc_" to your own prefix.

WARNING! DO NOT USE ON A LIVE STORE UNLESS YOU WANT TO LOSE EVERYTHING!

Code: Select all

DELETE FROM oc_address;
DELETE FROM oc_category;
DELETE FROM oc_category_description;
DELETE FROM oc_category_to_store;
DELETE FROM oc_coupon;
DELETE FROM oc_customer;
DELETE FROM oc_download;
DELETE FROM oc_download_description;
DELETE FROM oc_manufacturer;
DELETE FROM oc_manufacturer_to_store;
DELETE FROM oc_product;
DELETE FROM oc_product_description;
DELETE FROM oc_product_discount;
DELETE FROM oc_product_featured;
DELETE FROM oc_product_image;
DELETE FROM oc_product_option;
DELETE FROM oc_product_option_description;
DELETE FROM oc_product_option_value;
DELETE FROM oc_product_option_value_description;
DELETE FROM oc_product_related;
DELETE FROM oc_product_special;
DELETE FROM oc_product_to_download;
DELETE FROM oc_product_to_store;
DELETE FROM oc_review;
DELETE FROM oc_store;
DELETE FROM oc_store_description;
DELETE FROM oc_product_tags;
DELETE FROM oc_order;

Re: [MOD] - Remove All Demo Data

Posted: Mon Apr 12, 2010 11:21 pm
by Johnathan
Thanks, this will save time on future installations. One question: could you do this through using the "Restore" function with a file that has those queries?

Re: [MOD] - Remove All Demo Data

Posted: Tue Apr 13, 2010 12:13 am
by Qphoria
Theoretically it should work.

Re: [MOD] - Remove All Demo Data

Posted: Tue Apr 13, 2010 4:19 am
by cmebd
Brilliant - thanks muchly :-)

Re: [MOD] - Remove All Demo Data

Posted: Tue Apr 13, 2010 4:42 am
by OSWorX
Wondering why this is not an option with the installer as I am doing it with the German Edition:

1. installation with sample data (as it is now)
2. installation WITHOUT sample data

No need for any further action.

Re: [MOD] - Remove All Demo Data

Posted: Tue Apr 13, 2010 6:06 am
by Qphoria
Because rome wasn't built in a day

Re: [MOD] - Remove All Demo Data

Posted: Wed Apr 14, 2010 8:35 pm
by Chrissy Poo
Great Job!

Thank You :)

Re: [MOD] - Remove All Demo Data

Posted: Thu Apr 22, 2010 6:28 pm
by sykic
I think to get a completely emty store you need to add the following tables

oc_order_download;
oc_order_history;
oc_order_option;
oc_order_product;
oc_order_status;
oc_order_total;
oc_product_to_category;
oc_coupon_description;

perhaps an OC expert could confirm

Code: Select all

DELETE FROM oc_address;
DELETE FROM oc_category;
DELETE FROM oc_category_description;
DELETE FROM oc_category_to_store;
DELETE FROM oc_coupon;
DELETE FROM oc_customer;
DELETE FROM oc_download;
DELETE FROM oc_download_description;
DELETE FROM oc_manufacturer;
DELETE FROM oc_manufacturer_to_store;
DELETE FROM oc_product;
DELETE FROM oc_product_description;
DELETE FROM oc_product_discount;
DELETE FROM oc_product_featured;
DELETE FROM oc_product_image;
DELETE FROM oc_product_option;
DELETE FROM oc_product_option_description;
DELETE FROM oc_product_option_value;
DELETE FROM oc_product_option_value_description;
DELETE FROM oc_product_related;
DELETE FROM oc_product_special;
DELETE FROM oc_product_to_download;
DELETE FROM oc_product_to_store;
DELETE FROM oc_review;
DELETE FROM oc_store;
DELETE FROM oc_store_description;
DELETE FROM oc_product_tags;
DELETE FROM oc_order;
DELETE FROM oc_order_download;
DELETE FROM oc_order_history;
DELETE FROM oc_order_option;
DELETE FROM oc_order_product;
DELETE FROM oc_order_status;
DELETE FROM oc_order_total;
DELETE FROM oc_product_to_category;
DELETE FROM oc_coupon_description;
DELETE FROM oc_coupon_product;

Re: [MOD] - Remove All Demo Data

Posted: Thu Apr 22, 2010 8:01 pm
by Qphoria
Yea those few product ones and coupons should be added. There should be no orders by default and i left that code out incase someone might screw up their real site.

Re: [MOD] - Remove All Demo Data

Posted: Fri Jul 02, 2010 11:01 pm
by rich06
Shouldn't oc_url_alias also be added to the list?

Rich

Re: [MOD] - Remove All Demo Data

Posted: Fri Jul 02, 2010 11:07 pm
by JAY6390
Yeah it should. Think it was mentioned that in future releases the test data would be an option in the install process

Re: [MOD] - Remove All Demo Data

Posted: Sat Jul 03, 2010 3:13 am
by Qphoria
It was requested... not necessarily going to be there ;)

Re: [MOD] - Remove All Demo Data

Posted: Sat Jul 03, 2010 3:22 am
by JAY6390
Ah OK lol O0

Re: [MOD] - Remove All Demo Data

Posted: Tue Aug 17, 2010 11:19 pm
by Nayar
OSWorX wrote:Wondering why this is not an option with the installer as I am doing it with the German Edition:

1. installation with sample data (as it is now)
2. installation WITHOUT sample data

No need for any further action.
Agreed. Just as Joomla does.

However, it is not a priority for now as it is easy to delete the datas manually;)

Re: [MOD] - Remove All Demo Data

Posted: Fri Sep 17, 2010 4:27 am
by tommyla
would make sense to have a vanilla version without all the bloat, people are gonna remove it anyway, and everyone can test the store with the demo here or at some other place

meybe make a addon, like "demoproducts-install.zip" at google code instead of having every single release default to demo install ;)

this will make everyone happy so we dont need to upload over 100 useless files

Re: [MOD] - Remove All Demo Data

Posted: Fri Sep 17, 2010 4:40 am
by JAY6390
This is another good idea on how to streamline the code for opencart. I know Q has been working his butt off to reduce large repetitive code to smaller chunks of code, hopefully this will make it into a future release of opencart

Re: [MOD] - Remove All Demo Data

Posted: Wed Sep 29, 2010 10:55 pm
by SXGuy
I also think you should include the code to reset the increment count back to 0 as well, i dont really like the idea of new products starting from the last demo product ID etc.

Re: [MOD] - Remove All Demo Data

Posted: Fri Oct 01, 2010 10:32 am
by mgirouard
Howdy friends. I found this thread useful with a recent install so thanks :)

I've hacked up a quick PHP script which solves this problem, but in a little more OpenCart-ish way. Hopefully someone else finds it useful.

The Gist is available here:
http://gist.github.com/605619

and I've written up a quick example here:
http://www.lovemikeg.com/2010/09/30/cle ... mple-data/

Best to you all,
Mike G.

Re: [MOD] - Remove All Demo Data

Posted: Tue Nov 16, 2010 11:39 pm
by eyeweb
Just thought I would update this.

ALthough your script does the job, (well with some slight modifications, such as closing the php off ;) ), it could be far simpler.

Simply create a file called whatever you want (I go with delete demo-data.php) and copy the below into it).

Then place the file in your opencart install root (the same place where your config.php file is).

Visit the page in a browser i.e http://www.yourdomain.com/delete-demo-data.php

Once completed, simply delete the file from the root, job done :)

Code: Select all

<?
include('config.php');

$db = mysqli_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$tables = array(
    'address',
    'category',
    'category_description',
    'category_to_store',
    'coupon',
    'customer',
    'download',
    'download_description',
    'manufacturer',
    'manufacturer_to_store',
    'product',
    'product_description',
    'product_discount',
    'product_featured',
    'product_image',
    'product_option',
    'product_option_description',
    'product_option_value',
    'product_option_value_description',
    'product_related',
    'product_special',
    'product_to_download',
    'product_to_store',
    'review',
    'store',
    'store_description',
    'product_tags',
    'order',
    'order_download',
    'order_history',
    'order_option',
    'order_product',
    'order_status',
    'order_total',
    'product_to_category',
    'coupon_description',
    'coupon_product',
);

// for each table add a delete line to script
foreach ($tables as $table) {
    $query = "TRUNCATE TABLE `oc_$table`;";
    $result = mysqli_query($db, $query);
    if (!$result) {
        echo "<p>The data from $table was not deleted</p>";
    echo "<p>$query</p>";
    } else {
        echo "<p>The data from $table was deleted</p>";
    }
}

?>

Re: [MOD] - Remove All Demo Data

Posted: Tue Dec 07, 2010 4:00 am
by SapporoGuy
Does this also set the table counts back to zero?