I want to delete an order,but when I try to delete it notify me "This product is referenced by a line item on Order 40 and therefore cannot be deleted. Disable it instead" but I want delete it completely in my product list, It is not important delete an order item that is used in.
Commerce is protecting its own data integrity - if you were able to delete a product that's referenced by an order line, the next time you view the associated order something would break.
You'll need to remove the product from all associated orders before deleting it; I think the easiest way to do so would be to construct a View using Views Bulk Operations, select Line Items filtered by the relevant product ID, and bulk delete them. Obviously this will have an effect on existing orders, but since the product is attached to the line item by its ID, there isn't really an alternative (short of rewriting a bunch of stuff in Commerce).
I have also run into this problem with test products during a site build, and/or products in a large dataset that needed to be deleted post-import. Once the product is associated with orders or nodes, it is painful to get rid of them. Even after orders or shopping carts are deleted, the database records remain. Even Views Bulk Operations will not get around those.
So, here is my Product Removal Toolkit:
Install the fantastic module: https://www.drupal.org/project/commerce_prodnodelink
This will put a very handy box on your product pages that will tell you what node the product is referenced on so you don't have to go searching for it. Use the info there to delete the product references.
Now you have to go into the DB and do some SQL queries:
- commerce_line_item table:
delete from commerce_line_item where line_item_label = 'the-sku-of-the-product-here';
- field_data_commerce_product table:
delete from field_data_commerce_product where commerce_product_product_id = 'product-id-of-the-product-entity';
- field_revision_commerce_product table:
delete from field_revision_commerce_product where commerce_product_product_id = 'product-id-of-the-product-entity';
Once you do these things, you should be able to delete that product!
Now, if you really have a lot of items to get rid of, you could make arrays with your errant line item data and funnel it all through a PHP function. :P