Unavailable attributes

0
Hi, I have a domain model with 2 entities: Product and Cart. I have a page with products and if I want to buy a product, after I press a button “Add to cart”, the product should appear in the cart (I also have a page called “Cart”). In this page called “Cart”, the products should retrieve the attributes “Name” and “Description” from Product entity, but when I want to select the data source for the 2 columns from Cart page (you can see that in the screenshots below), the association between Product and Cart is not available, so I can’t use the attributes from Product entity for the Cart page. I will attach screenshots with the domain model (1), the Cart page (2), the problem with the data source for the 2 columns from Cart page (3) and the microflow associated to the “Add to cart” button (4). Could you tell what’s the problem? Thank you!
asked
1 answers
0

Hi Valentin,

 

Your domain model is bugging you.

Your Product entity associates to the Cart entity 1-8 Where one product refers to a single cart and a Cart can be referenced by multiple Products. This last part bugs you in your page. Since multiple Products cab refer a Cart, you can not show the Product/Name, as this would be multiple.

Secondly, your Product can be ordered once, since it can only refer a single Cart.

Third, you have an enum “AddedToCart” in your product. Which isn’t a characteristic of the Product, but of the relation of the Product to a Cart. Since it will be added to a Cart multiple times. As you have modeled you can only add it to a Cart ones.

So you need the following domain model.

 

Adding to cart can be done by

  1. Press button add to cart
  2. Get Cart object, if not exists create
  3. Create Cart item and
    1. set association between Cart and NewCartItem
    2. set association between NewCartItem and Product
  4. Show on page
    1. Dataview datasource context Cart
    2. List datasource association Cart -> CartItem
answered