I'm looking for a way to delete all of the test orders, addresses, shipments, etc from our development site. We have over 100 products and about 15 categories setup, so I really don't want to have to import everything to a new database.
The DELETE statement conflicted with the REFERENCE constraint "FK_uCommerce_ShipmentDiscountRelation_uCommerce_Discount". The conflict occurred in database "schema.mydb", table "dbo.uCommerce_ShipmentDiscountRelation", column 'DiscountId'.
How do you clear test orders in uCommerce 2
I'm looking for a way to delete all of the test orders, addresses, shipments, etc from our development site. We have over 100 products and about 15 categories setup, so I really don't want to have to import everything to a new database.
Hi Javier,
Deleting Purchase Orders and Baskets from the Database in uCommerce works for 1.0.
There's an update for the script for 2.0:
BEGIN TRAN
-- Delete reviews
DELETE FROM uCommerce_ProductReviewComment
DELETE FROM uCommerce_ProductReview
-- Delete discounts
DELETE FROM uCommerce_OrderLineDiscountRelation
DELETE FROM uCommerce_Discount
-- Remove shipment <-> order line link
UPDATE uCommerce_OrderLine SET ShipmentId = NULL
UPDATE uCommerce_PurchaseOrder SET BillingAddressId = NULL
DELETE FROM uCommerce_Shipment
DELETE FROM uCommerce_OrderAddress
DELETE FROM uCommerce_OrderProperty
DELETE FROM uCommerce_OrderLine
DELETE FROM uCommerce_Payment
DELETE FROM uCommerce_OrderStatusAudit
DELETE FROM uCommerce_PurchaseOrder
DELETE FROM uCommerce_Address
DELETE FROM uCommerce_Customer
--COMMIT
Thank you Soren, that worked perfectly. How about a script to delete a product by ID or a store by ID?
When using Ucommerce v.3 change the script above to this:
BEGIN TRAN
-- Delete reviews
DELETE FROM uCommerce_ProductReviewComment
DELETE FROM uCommerce_ProductReview
-- Delete discounts
DELETE FROM uCommerce_OrderLineDiscountRelation
DELETE FROM uCommerce_Discount
-- Remove shipment <-> order line link
UPDATE uCommerce_OrderLine SET ShipmentId = NULL
UPDATE uCommerce_PurchaseOrder SET BillingAddressId = NULL
DELETE FROM uCommerce_Shipment
DELETE FROM uCommerce_OrderAddress
DELETE FROM uCommerce_OrderProperty
DELETE FROM uCommerce_OrderLine
DELETE FROM uCommerce_PaymentProperty
DELETE FROM uCommerce_Payment
DELETE FROM uCommerce_OrderStatusAudit
DELETE FROM uCommerce_PurchaseOrder
DELETE FROM uCommerce_Address
DELETE FROM uCommerce_Customer
--COMMIT
hey i get this
thanks.
KJ
Use this for version 3:
BEGIN TRAN
-- Delete reviews
DELETE FROM uCommerce_ProductReviewComment
DELETE FROM uCommerce_ProductReview
-- Delete discounts
DELETE FROM uCommerce_OrderLineDiscountRelation
DELETE FROM uCommerce_ShipmentDiscountRelation
DELETE FROM uCommerce_Discount
-- Remove shipment <-> order line link
UPDATE uCommerce_OrderLine SET ShipmentId = NULL
UPDATE uCommerce_PurchaseOrder SET BillingAddressId = NULL
DELETE FROM uCommerce_Shipment
DELETE FROM uCommerce_OrderAddress
DELETE FROM uCommerce_OrderProperty
DELETE FROM uCommerce_OrderLine
DELETE FROM uCommerce_PaymentProperty
DELETE FROM uCommerce_Payment
DELETE FROM uCommerce_OrderStatusAudit
DELETE FROM uCommerce_PurchaseOrder
DELETE FROM uCommerce_Address
DELETE FROM uCommerce_Customer
--COMMIT
This script thread is again long overdue.
is working on a reply...