0121 31 45 374
Qoute Icon

Delete all products and orders from Ucommerce

Tim

Here's an updated script to delete all the products, orders and any other testy type data from Ucommerce. This is an updated version of my previous script to delete all product and order data from Ucommerce and accommodates Ucommerce's new database schema for prices.


BEGIN TRAN   DELETE FROM uCommerce_ProductReviewComment
DELETE FROM uCommerce_ProductReview
DELETE FROM uCommerce_OrderLineDiscountRelation
DELETE FROM uCommerce_ShipmentDiscountRelation
DELETE FROM uCommerce_Discount
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
-- NOTE: Only needed if you use our Stripe package
DELETE FROM uCommerce_StripeCustomer
DELETE FROM uCommerce_Customer   DELETE FROM uCommerce_ProductRelation
DELETE FROM uCommerce_ProductProperty
DELETE FROM uCommerce_ProductDescriptionProperty
DELETE FROM uCommerce_ProductDescription
DELETE FROM uCommerce_CategoryProductRelation
DELETE FROM uCommerce_PriceGroupTarget
DELETE FROM uCommerce_ProductPrice
DELETE FROM uCommerce_Price
DELETE FROM uCommerce_Product   -- Just double check things have gone
SELECT * FROM uCommerce_PurchaseOrder o
SELECT * FROM uCommerce_Product p   -- For safety's sake, run it in a transaction just in case you change your mind
ROLLBACK TRAN
-- When happy it works, uncomment this line and comment out the ROLLBACK
-- COMMIT TRAN

Liked this post? Got a suggestion? Leave a comment