[TYPO3-mvc] repository->add => persistenceManager->persistAll => repository->findBy
Daniel Dimitrov
danielsd_bg at yahoo.fr
Mon Jul 12 08:43:40 CEST 2010
Hey Franz,
First thank you for the reply!
"Franz Koch" <typo3.RemoveForMessage at elements-net.de> wrote in message
news:mailman.1.1278894693.15783.typo3-project-typo3v4mvc at lists.typo3.org...
> Hey,
>
>> My Cart model is defining the product as follow:
>> /**
>> * @var Tx_BwShop_Domain_Model_Products
>> */
>> protected $product;
>
> I'm kind of confused by your domain structure and naming, so I'm not sure
> where the problem could come from. As it seems, your cart can only have
> one product? If so, then the class name of the model feels odd as it
> implicates plural - or might this be misspelled and be the error?
Ok, I slowly start to see why we need good names :)
products is the model that I use in list view
product is the model that I use in single view
They both map the same table, but the first one (products) has just 2
properties - name and author.
and Product on the other side has around 20-30 properties.
>
> If you on the other hand allow multiple products (which I assume) in your
> cart, then you don't need a "product" property, but a "products" (plural)
> and make it a objectStorage:
>
> /**
> * The products currently in the cart
> * @var
> Tx_Extbase_Persistence_ObjectStorage<Tx_BwShop_Domain_Model_Product>
> */
> protected $products;
>
>
> Maybe there is the error?
My cart stores the date and the product_id. The product id is not an
mm_relation, but 1:1 relation.
cart table
id date product_id
1 "12.07.2010 08:30" 20
2 "12.07.2010 08:30" 3000
The cart works when I refresh the page. My index action looks like this:
public function indexAction() {
$sessionId = $this->cartModel->getUserSessionId();
$productsInCart = $this->cartRepository->findBySessionId($sessionId)
$this->view->assign('products',$productsInCart);
}
and I use the same code to get my products in addToCartAction.
The only difference is that the AddToCartAction function is called in the
context of an ajax call(using page type for this).
As I said after the ajax call the right data is saved in the cart, but no
mapping for the inserted row is made.
>
> --
> kind regards,
> Franz Koch
Kind regards,
Daniel
More information about the TYPO3-project-typo3v4mvc
mailing list