Saleor: Possible issue with CheckoutLine disappearing when a product is deleted from shop

Created on 29 May 2020  路  3Comments  路  Source: mirumee/saleor

Hi guys,
I'm reading your code to see if we'd like to migrate to it from woocomecer which as very poorly written inventory management. One thing I've noticed is that you have on_delete=cascade in CheckoutLines on foregin key to varinats, does this mean that if i remove a variant from my shop all orders that had this variant will disappear as well?
https://github.com/mirumee/saleor/blob/master/saleor/checkout/models.py#L178

Most helpful comment

Hi guys,
I'm reading your code to see if we'd like to migrate to it from woocomecer which as very poorly written inventory management. One thing I've noticed is that you have on_delete=cascade in CheckoutLines on foregin key to varinats, does this mean that if i remove a variant from my shop all orders that had this variant will disappear as well?
https://github.com/mirumee/saleor/blob/master/saleor/checkout/models.py#L178

it's not - you can "safely" delete product / product variant.
Each order is made of multiple order lines (variants in order). After you delete product variant, you will only delete relation OrderLine - ProductVariant as FK, but it's not a big deal, as product variant name is stored in OrderLine object also.

So summing up - we (I'm not part of Saleor to be clear, we are just some shop running saleor) deleted variants and it didn't really matter for past orders.

Although it might be a problem, with unfulfilled orders, as there is also allocations etc. so most likely you won't be able to fulfill order with deleted variant, but that's nothing strange I guess - you should not do it anyway

All 3 comments

Hi guys,
I'm reading your code to see if we'd like to migrate to it from woocomecer which as very poorly written inventory management. One thing I've noticed is that you have on_delete=cascade in CheckoutLines on foregin key to varinats, does this mean that if i remove a variant from my shop all orders that had this variant will disappear as well?
https://github.com/mirumee/saleor/blob/master/saleor/checkout/models.py#L178

it's not - you can "safely" delete product / product variant.
Each order is made of multiple order lines (variants in order). After you delete product variant, you will only delete relation OrderLine - ProductVariant as FK, but it's not a big deal, as product variant name is stored in OrderLine object also.

So summing up - we (I'm not part of Saleor to be clear, we are just some shop running saleor) deleted variants and it didn't really matter for past orders.

Although it might be a problem, with unfulfilled orders, as there is also allocations etc. so most likely you won't be able to fulfill order with deleted variant, but that's nothing strange I guess - you should not do it anyway

@PiotrCzapla CheckoutLine model represents an item in the checkout, so a state before creating the actual order. If you remove a variant, you won't be able to buy it, so any existing checkout lines are removed. When the checkout process is completed, we create a new Order with OrderLine instances. These models are pretty similar, but there we don't use foreign keys but instead, we copy data from the checkout and checkout lines e.g. product name or SKU. This ensures that removing products from the shop doesn't remove any information from the existing orders.

Thx for clarification. I will give saleor a go. It will be our backend system for start, to clean up the mess woocomerce is doing with it's faulty inventory management. and once it is running smoothly we will consider switching over.

Was this page helpful?
0 / 5 - 0 ratings