Im currently making some type of webshop but i can’t figure something out. What I want is: - When i change the price, amount (or any other attribute) of a product, I want to keep the data from purchases that were made before the change. - Example: Let’s say i buy a bottle for 20$. A few days later the price of the product changes in the webshop from 20$ to 15$. → After the price drops, I still want to see my purchase history (the 20$ payment) My domain model is very simple at the moment: - [Account] 1 <--- * [ShoppingCart] 1 <--- * [ShoppingCartProduct] * ---> 1 [Product]
I think the best way to do this is to create a Price entity that is associated with the product.
Next to a price attribute within this entity you can also set a price from and enddate to make sure you can see which price belongs to the product at which point in time.
As an alternative to Maarten’s solution, you can store historic data in a separate domain model – analogous to offloading such data to a data warehouse for BI purposes.
You can duplicate your domain model, and when a customer places and order, you can use the Clone function from the CommunityCommons module to duplicate your operational data to your historic domain model.