Tuesday, February 28, 2012

MVC design for shopping cart

Hi,

I'm currently trying to create a shopping cart solution with cake 1.3.
In the current design, only the product id of a chosen product will be
saved in the session, each time the customer lists the cart items, all
information needs to be read out of the database.
My idea was to create a seperated model (no relation to any table)
where all cart calculations can happen in, which can then be used in
several controllers. However, this would mean that this cart class
would need to use several other product related models (product
details, taxes, countrydetails, etc.), which is not easily supported
by cake, since it breaks the MVC model.
The workaround would be to implement the logic in a controller where I
can easily access all models, however, this breaks two other basics,
once the "fat model skinny controller" rule and on the other hand the
code is not easily reusable for other purposes.

My question is now how where to implement the cart functionality (e.g.
summary price, discount, taxes calculation, etc.) without breaking MVC
but with sticking to "fat model skinny controller" and the re-
usability of my code.

Thanks,
Christian

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: