How to Delete All Products from VirtueMart?

Warning: This post is about removing content from your database, specifically your VirtueMart e-commerce/store tables. If this is not what you want then please stop reading now. itoctopus claims no responsibility (neither explicit nor implicit) whatsoever if you accidentally remove data that you later need.

Before you begin you need to download a backup and make a copy of your whole Joomla database, including your VirtueMart tables (we know that a backup is sufficient, but the copy will expedite the reversal of errors should your website becomes inoperable because of an accidental deletion of a system table for example):

Download a backup your Joomla database

The first thing to do is to download a backup of your Joomla database to your local machine. This can be easily done from cPanel (if you don’t have cPanel then ask your hosting company to do the backup for you):

  • Login to your cPanel account. You can usually do so by going to http://yourjoomlawebsite.com/cpanel or http://yourjoomlawebsite.com:2083 and enter the login credentials supplied to you by your web hosting company.
  • Once you’re logged in to cPanel, you should click on Backups (under Files), click the name of your database under Partial BackupsDownload a MySQL Database Backup, and then wait for your database to be downloaded.

Copy Your Joomla Database

Copying your Joomla database is an extra security measure in case something goes wrong. When you have an immediate copy of your Joomla database, then you can just rename the original database to something like myjoomladatabse_old and rename the copy to myjoomladatabase and everything will work as before.

Here’s what you should do to make the copy:

  • Login to your cPanel account as described above and then click on the phpMyAdmin icon under Databases.
  • You should now be logged in automatically to phpMyAdmin. The next thing to do is to click on your database name, and then click on Operations on the top right, and then under Copy Database to: enter the name of the database copy, which should be something like yourjoomladatabase2 (where yourjoomladatabase stands for the current name of the database), and then click on Go. The process may take some time in case you have a lot of data on your website. Once the copy process is done, you will see something like Database yourjoomladatabase has been copied to yourjoomladatabase2.

Now that you’ve done the above, you can go ahead with the deletion of all your products in your VirtueMart store. Here’s how it should be done:

  • Go to phpMyAdmin (the process of going to phpMyAdmin has already been described above)
  • Click on the name of the database of your Joomla website. In our example, the name of this database is yourjoomladatabase.

Now there are two methods for deleting your data, Method #1 and Method #2. Method #1 takes more time but is non-technical, Method #2 can be done in a significantly shorter time but is a bit more technical:

  • Method #1: Click on the name of your Joomla database in phpMyAdmin, and then click on the Empty icon next to the table jos_vm_product. This will delete all the products in your database. You should also do the same for the following tables:
    • jos_vm_product_attribute
    • jos_vm_product_attribute_sku
    • jos_vm_product_category_xref
    • jos_vm_product_discount
    • jos_vm_product_download
    • jos_vm_product_files
    • jos_vm_product_mf_xref
    • jos_vm_product_price
    • jos_vm_product_product_type_xref
    • jos_vm_product_relations
    • jos_vm_product_reviews
    • jos_vm_product_type
    • jos_vm_product_type_parameter
    • jos_vm_product_votes

    The above tables hold information that relates to your existing products. Not deleting them will cause confusion with VirtueMart in case you decide to add products to your VirtueMart store again.

  • Method #2: Click on the name of your Joomla database in phpMyAdmin and copy the following code:

    TRUNCATE TABLE `jos_vm_product`;
    TRUNCATE TABLE `jos_vm_product_attribute`;
    TRUNCATE TABLE `jos_vm_product_attribute_sku`;
    TRUNCATE TABLE `jos_vm_product_category_xref`;
    TRUNCATE TABLE `jos_vm_product_discount`;
    TRUNCATE TABLE `jos_vm_product_download`;
    TRUNCATE TABLE `jos_vm_product_files`;
    TRUNCATE TABLE `jos_vm_product_mf_xref`;
    TRUNCATE TABLE `jos_vm_product_price`;
    TRUNCATE TABLE `jos_vm_product_product_type_xref`;
    TRUNCATE TABLE `jos_vm_product_relations`;
    TRUNCATE TABLE `jos_vm_product_reviews`;
    TRUNCATE TABLE `jos_vm_product_type`;
    TRUNCATE TABLE `jos_vm_product_type_parameter`;
    TRUNCATE TABLE `jos_vm_product_votes`;

    and then click on SQL on the top of phpMyAdmin (while you’re in the same database), and then paste the code above, and then click on Go. This will delete all the tables in one shot (instead of you clicking on the Empty button next to each and every table).

  • Now that you’ve deleted the products from the database, you will also need to delete the images associated with these products. We suggest that you only proceed with this after downloading a full backup of your website. Once that is done, you will need to login through FTP to your website, and then delete the product folder located under /public_html/components/com_virtuemart/shop_image/. A more expedient way of doing this is logging in to cPanel, and then clicking on File Manager under Files (on the cPanel homepage), and then deleting the /public_html/components/com_virtuemart/shop_image/product/ folder

Now if you want to delete all your products from your VirtueMart store and you feel that the above is a bit too technical, then we’ll be happy to do it for you. All you need to do is to contact us. We’ll take care of this in no time and at very low cost.

2 Responses to “How to Delete All Products from VirtueMart?”
  1. Comment by jens — May 16, 2014 @ 4:39 am

    This info is not valid (anymore?) for virtuemart version 2.6.0

    The table structure is different:

    TRUNCATE TABLE `#_virtuemart_product_categories`;
    TRUNCATE TABLE `#_virtuemart_product_customfields`;
    TRUNCATE TABLE `#_virtuemart_product_manufacturers`;
    TRUNCATE TABLE `#_virtuemart_product_medias`;
    TRUNCATE TABLE `#_virtuemart_product_prices`;
    TRUNCATE TABLE `#_virtuemart_product_shoppergroups`;
    TRUNCATE TABLE `#_virtuemart_product_products`;
    TRUNCATE TABLE `#_virtuemart_products_#languagecode#_#languagecode#;

    There are some tables which could exist several times, if the shop is multi language like
    #_virtuemart_products_fr_fr
    #_virtuemart_products_en_gb
    and so on

  2. Comment by Fadi — June 16, 2014 @ 8:36 am

    Hi Jens,

    Thank you for sharing this information with us.

Leave a comment