[TYPO3-mvc] Architectural question: Shoppingcart

Nikolas Hagelstein hagelstein at shr.cc
Wed May 5 11:21:13 CEST 2010


Hi there,

I am currently modeling a shopping cart functionality and would like to hear
your opinion about my approach.
I feel a little unhappy about its design.

I got the following involved models:
- Product
- ShoppingCart
- ShoppingCartItem
- ShoppingCartItemConfigurationItem

ShoppingCarts holds an array of shoppingCartItems

ShoppingCartItem consists of: 
- product - referring to an instance of Product
- quantity just an integer 
- configurations: an array of ShoppingCartItemConfigurationItem.

Configuration is needed since every Product can be configured in a different
manner,
meaning it can have optional things set that effect e.g. the final price.

Note: ShoppingCart, ShoppingCartItem, ShoppingCartItemConfigurationItem do
not extend entity or value object since they should not be persisted (At
least not to the database).

Things I feel unhappy/unsure about:
1. ATM the involve controllers access the shoppingCart via a domain service.
 
2. I am using a domain service, because I feel the shoppingCart model itself
should'nt be responsible for things like: fetching a product by productCode,
create an instance of ShoppingCartItem etc.

3. This shoppingCart domain service uses a session service to load/store the
shoppingCart to the session. This feels a little ugly to me. But I am not
aware of a better way.

The shoppingCart (or it's accesing service). Needs to be able to do the
following:

Add a certain quantity of product x:
Remove a Product:
Maintain the configuration of a particular product instance.
Calculate the overallPrice 
Calculate the overallQuantity (easy).


I hope this was clear enough.  

Cheers,
Nikolas



More information about the TYPO3-project-typo3v4mvc mailing list