[TYPO3-mvc] Extensionbuilder relation question
Jan Kornblum
jan.kornblum at gmx.de
Tue Apr 30 22:58:27 CEST 2013
Hi again,
hmm, nobody out there who knows a little bit more about this than me?
I've just recognized the following:
a) when i create a model "category" which has a relation (1:n) to a
model "product", in ext_tables.sql there is a field (int(11)...) in
both tables for the opposite side / model.
b) when i create a model "product" which has a relation (n:1) to the
model "category", in ext_tables.sql there is a field (int(11)...) only
on "product" table's side.
Can anybody explain this different behaviour on sql-side to me?
Having placed the relation on "product" side, like described in b), i
am able to access $product->getCategory(). But i must also be able to
access $category->getProducts() and i tried to accomplish this by doing
the following:
1. Adding the missing "int(11) not null default 0" field to
"tx_domain_model_category"
2. Adding $this->products, SetProducts(), GetProducts(), AddProduct(),
RemoveProduct() methods in the CategoryModel.php
3. Adding a field (config->type = passthrough) to the "Category"-TCA
This should be all necessary steps to get the relation work in the
opposite direction, but it isn't... Can anybody give me a hint about
what is missing or wrong?
I think it has something to do with my TCA: When i vardump all
$categories, each category has a property "products", its type seems to
be correct, but it is always null / empty. I've recognized that when
the additional TCA field "products" inside the TCA of "Category" is
changed to "inline" instead of "passthrough", and Product-records are
created inside the category-record using the IRRE form, they can be
accessed by $category->getProducts() correctly. But when i just create
a "Product" record and choose a "Category" by the selectbox, this
Product cannot be accessed by $category->getProducts()...
Kind regards, Jan
More information about the TYPO3-project-typo3v4mvc
mailing list