Created
January 9, 2012 13:23
-
-
Save dator-zz/1582913 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 tables: Product, Category, ProductCategory | |
A product has many categories and a category can belong to many products. | |
The category objet is nestedset(via doctrine behavior) with a parent, and a position. | |
I need to be able to manage these categories (up/down/delete/new/edit) | |
I need to be able to add many categories to a product. | |
AFAIK, when a category (cat1) has a parent (cat0), and you want to add cat1 to a product, you need to add cat0 too. | |
Is there a simple way to handle these recommandation? | |
Thanks a lot ^â |
In fact the context isn't clear to me : 2 logics are in "collision" ?
The nested tree "business logic" apply to the productcategory ? Is this assert true : "If a product is linked to a category, every parent category are also "defacto" linked to the product ?"
- Are we talking about doctrine 1.2 ?
- What's your query need ? Showing all categories including the parent on the product page AND fetching all product for a given category all right ?
- could you gist your schema ?
- I may have some old code about that (for backend purpose) yet it's not Open Source oriented (mean : maybe a bit dirty/specific), I would be sure it match your need before sharing it with you.
- The assertion is true :)
- Yes, doctrine 1.2
- So, All categories, including the parent if the category has at least one product.
- schema : https://gist.github.com/da6be3b29bb9acb3125e
- OK ^^
Thanks a lot!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to my recent test in database, if i add product1 to cat1, this doesnt work as expected, it's need cat0 too (the parent).
Maybe i'm wrong and when you save your object in database it handle it well ^^
Do you have some widget/validator to handle manytomany nestedset association? :)