How can I update the stock attribute of a product in the Product entity when the quantity of that product in the cart is edited by a user?

0
I have three entities in my Mendix app: Product, OrderLine, and Cart. When a user edits the quantity of a product in the cart, I want to update the stock attribute of the corresponding product in the Product entity. Could someone please guide me through the steps to achieve this?
asked
1 answers
0

Hi Muhammed,

 

I would recommend to only update your stock on the moment that people order to simplify your request.

For that you create a microflow on a button. The cart should be passed in as parameter.

  1. Then you can retrieve your product over the association from the cart.
  2. Then you can add a change object activity to change the product.
  3. Then you can set the stock member of the product to be stock of the product - order quantity.
  4. Then you commit your order and all associated data.

 

This should update your stock quantity. (please be aware you still need to validate and all for negative amounts etc.).

answered