Import created duplicate products

A forum where issues related to the DataPort utility can be discussed.
Post Reply
SethMW
Ensign (ENS)
Ensign (ENS)
Posts: 15
Joined: Wed May 06, 2009 4:29 pm

Import created duplicate products

Post by SethMW » Fri Jul 10, 2009 4:35 pm

I did an export/import, and the import ended up creating new product records. I was going to restore my DB backup, but I'm getting some SQL error with that. Can I just do a DELETE FROM ac_Products WHERE ProductId < N? Will deletes cascade properly? If not, should I delete from other related tables, too?

It would be so much easier than figuring out why SQL Server is complaining. I've never seen the error before, and I've never really worked with this server before, so I don't know if it has issues.

Thanks,
Seth

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Import created duplicate products

Post by mazhar » Mon Jul 13, 2009 5:15 am

If you want to delete products from store better make use of AbleCommerce API to carryout this job. Here is a code snippet that can delete all products from store

Code: Select all

foreach (Product product in Token.Instance.Store.Products)
            product.Delete();
if you want to delete all products having product id less then some numeric value.

Code: Select all

int numaricValue = 7777;
        foreach (Product product in Token.Instance.Store.Products)
            if (product.ProductId < numaricValue)
                product.Delete();
All you need to do is to place this code at some location from where you can trigger it. With this approach API will take care of cascading product associations.

Post Reply