[TYPO3-mvc] 1 to many relation

Christian von Rohr ch.vrohr at gmail.com
Wed Jan 16 10:34:03 CET 2013


Hi Frederico,

Think it´s a "n:1" relation for the product to the category and the opposit
way a "1:n" relation (useful if you generate with the ExtensionBuilder).
So every product has one category, but a category can have one or more
(0..n) products.

But instead of creating a property on both sites, you find your products
with your ProductRepository. Hence only a category attribute on the product
is needed ("n:1").
Looks something like this:
$productRepository->findByCategory($categoryEntity);

Cheers
Chris




2013/1/16 Kay Strobach <typo3 at kay-strobach.de>

> It is an m to n relation. Is possible in flow / extbase i doubt there
> was an example in the docs.
>
> I think you need to store e.g. the categorie id's in the product.
> Than you can iterate over the products to show all products of a
> category. Additionally the product nows all it's categories.
>
> To improve speed it could also be sensefull to just store the
> information in the categorie and do it vice versa.
>
> Regards
> Kay
>
> Am 15.01.13 14:36, schrieb Federico Bernardin:
> > Hi,
> > I develop a plugin with 2 entities:
> > category and product.
> > I need to know what is the category when a product is chosen and I need
> to know what are products related when one category is chosen.
> > The relation is 1 category many products.
> > I have created category property into product entity.
> >
> > How can access the list of product when I know only category entity?
> > Should I create a property to map the relation between category and
> product in category entity?
> >
> > Thanks
> > Federico
> >
>
>
> --
> http://www.kay-strobach.de - Open Source Rocks
>
> TYPO3 .... inspiring people to share!
> Get involved: http://typo3.org
>
> Answer was useful - feel free to donate:
>   -
>
> https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KPM9NAV73VDF2
>   - https://flattr.com/profile/kaystrobach
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>


More information about the TYPO3-project-typo3v4mvc mailing list