# |
Apr 9th 2019, 07:21 |
neon1024 |
They would be |
# |
Apr 9th 2019, 07:21 |
neon1024 |
That would be my approach anyway :slightly_smiling_face: |
# |
Apr 9th 2019, 07:21 |
spriz |
but those AssociatedProduct need to be other `Product`entities |
# |
Apr 9th 2019, 07:21 |
neon1024 |
Then you could customise the property name depending on the AssociatedProductTypes.name |
# |
Apr 9th 2019, 07:21 |
neon1024 |
So then I’d have a product, and a nice ’associated_products` entity property with an array of products |
# |
Apr 9th 2019, 07:20 |
neon1024 |
`$this->Products->find()->contain(['AssociatedProducts' => function (Query $q) { return $q->where(['AssociatedProducts.association_type_id' => 1]); } ]);` |
# |
Apr 9th 2019, 07:20 |
spriz |
Ah I see |
# |
Apr 9th 2019, 07:19 |
neon1024 |
Product hasMany AssociatedProduct |
# |
Apr 9th 2019, 07:19 |
neon1024 |
AssociatedProduct belongsTo Product |
# |
Apr 9th 2019, 07:19 |
neon1024 |
Many rows |
# |
Apr 9th 2019, 07:19 |
neon1024 |
As the association would be to the product |
# |
Apr 9th 2019, 07:19 |
spriz |
then how would that link 2 products :thinking_face: ? |
# |
Apr 9th 2019, 07:18 |
neon1024 |
It would only have product_id |
# |
Apr 9th 2019, 07:18 |
neon1024 |
It would not, no. |
# |
Apr 9th 2019, 07:18 |
neon1024 |
Then I could get any product, and get all it’s associations by type |
# |
Apr 9th 2019, 07:18 |
spriz |
but it would still contain `product_source_id` and `product_target_id` I guess? |
# |
Apr 9th 2019, 07:18 |
neon1024 |
So I could have a table with all the associations |
# |
Apr 9th 2019, 07:18 |
neon1024 |
Probably with a ‘many-to-many’ join |
# |
Apr 9th 2019, 07:18 |
neon1024 |
Then my UI would be a multi select of products for each type |
# |
Apr 9th 2019, 07:17 |
neon1024 |
@spriz I’d have another table for ‘product_associations’, with id, product_id, association_type_id |
# |
Apr 9th 2019, 07:15 |
spriz |
@conehead sounds like beforeMarshal :slightly_smiling_face: |
# |
Apr 9th 2019, 06:50 |
conehead |
Oh. BeforeValidate does not exist anymore |
# |
Apr 9th 2019, 06:45 |
conehead |
What would be the best place to convert date strings to date objects before saving. In before validate? Before save? |
# |
Apr 8th 2019, 19:08 |
blackjccl |
please help |
# |
Apr 8th 2019, 19:08 |
blackjccl |
He called the class well ´$pdf = new TCPDF('L',PDF_UNIT,PDF_PAGE_FORMAT,TRUE,'UTF-8',FALSE);´ |
# |
Apr 8th 2019, 19:07 |
blackjccl |
I do not know if in my configuration I have to do something else |
# |
Apr 8th 2019, 19:06 |
blackjccl |
Hi community I'm using plugin CakePdf with the library tcpdf and when generating the pdf it shows me the following error |
# |
Apr 8th 2019, 16:41 |
spriz |
But yes - indeed many products can be “alternatives”, “related”, “similar” etc (type) to many other products :) |
# |
Apr 8th 2019, 16:40 |
spriz |
I’m not saying I don’t agree - but I need more explanation :D |
# |
Apr 8th 2019, 16:40 |
spriz |
@neon1024 what would the benefit in your opinion? It would have still have 2 different product_id columns and some type and source |
# |
Apr 8th 2019, 16:14 |
rogerpro |
Thanks @rochasmarcelo. The field is in an association. I will try that in a while. |
# |
Apr 8th 2019, 16:10 |
rochasmarcelo |
@rogerpro I think you could add a virtual field for it and add to allowed search fields |
# |
Apr 8th 2019, 15:48 |
neon1024 |
I would guess that @spriz use-case is probably more complex |
# |
Apr 8th 2019, 15:48 |
neon1024 |
Which would be `product_variants` or similar. Like I said, normalize into association |
# |
Apr 8th 2019, 15:48 |
rogerpro |
I guess he needs many alternatives for each product |
# |
Apr 8th 2019, 15:39 |
neon1024 |
Or normalizing the differences to an association? |
# |
Apr 8th 2019, 15:38 |
neon1024 |
@spriz Why not a self-referencing table? |
# |
Apr 8th 2019, 15:36 |
neon1024 |
I want to see if the string appears twice |
# |
Apr 8th 2019, 15:35 |
neon1024 |
Anyone know if there is a method of like `assertResponseContains($string, $numberOfInstances)` |
# |
Apr 8th 2019, 15:35 |
neon1024 |
So the test suite provides `assertResponseContains` |
# |
Apr 8th 2019, 15:03 |
rogerpro |
It makes sense, @spriz |