At the moment when an order is created it saves the products as orderItems linked to the Order.
The orderItem class - correctly - saves the current price of the item, as this could change in the future and that can't affect orders/invoices in the past. The order should be immutable.
But the product itself is linked to only by product id.
So if the product name is changed in the future, older orders would inherit that change.
Some may argue never to change product names, but that's not realistic and shop owners will do that. There are times you would want to (ie a small name change or a vintage year in a wine) and you don't want to create a new product for SEO or other reasons.
It would be confusing to the customer and the administrators if older orders suddenly change their contents, even if subtly.
My suggestion is the current product name is also copied in to the OrderItem. This would make it immutable and would mean a site owner could rename or even delete the product in the future without any impact on previous orders.
It will be great to have this option. So we can delete old products, but keep orders for statistics. For now, I have added product and product variant trash (archived_at column), so we can archive some older products/variants and not affect orders.
I don't like the idea of deleting products from the database, no matter if the title is copied to the order.
but otherwise, I'm totally for this functionality - keeping some sensible (legally binding) data copied on order / order items.
Think this is one of the major things missing right now to be compliant with laws. Not everyone integrated invoice PDF probably yet ;-)
With time there are a lot of products to delete. Like right now the migrated database has 6034 products with 23667 variants. I clean out the old stuff and the new Sylius database ends up with 3016 products with 14344 variants. That's a lot of old stuff, and they have been clearing the old database over the years. The stuff may look the same, but it gets new SKU's, so they need to add new products anyway.
@johnrisby is working on a PR ;-)
@psihius personally, I'm against deleting products from the database. archiving them is one thing, but deleting is a slippery slope to me.
imagine what would happen, from the reporting / accounting point of view if you would have 1 SKU for 2 different products - one from 10 years ago, one from today.
Most helpful comment
I don't like the idea of deleting products from the database, no matter if the title is copied to the order.
but otherwise, I'm totally for this functionality - keeping some sensible (legally binding) data copied on order / order items.