-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Association] Associated products #3165
Conversation
public function thereAreFollowingAssociationTypes(TableNode $table) | ||
{ | ||
foreach ($table->getHash() as $row) { | ||
$associationType = new AssociationType(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use the factory method here.
->createQueryBuilder('p') | ||
->setMaxResults(1) | ||
->getQuery() | ||
->getOneOrNullResult() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either setMaxResults(1)
or getOneOrNullResult()
*/ | ||
class AssociationInheritanceMetadataSubscriber implements EventSubscriber | ||
{ | ||
const ASSOCIATION_CLASS_NAME = 'Sylius\Component\Association\Model\Association'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
3360843
to
17919de
Compare
/** | ||
* @author Łukasz Chruściel <lukasz.chrusciel@lakion.com> | ||
*/ | ||
interface AssociatableInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Associable
without ta
is correct! ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is indeed associable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
dd9ce5e
to
73f1cba
Compare
@@ -21,6 +21,10 @@ Feature: Products | |||
| Black T-Shirt | 19.99 | T-Shirt size | T-Shirt fabric:Cotton | | |||
| Mug | 5.99 | | | | |||
| Sticker | 10.00 | | | | |||
And there are following association types: | |||
| name | code | | |||
| Cross sell | PAs1 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we automatically generate the code as it doesn't have any specific role in the scenarios?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention in a file is to write them explicitly. I think that it will be better to be consistent.
73f1cba
to
d0a029e
Compare
All review comments were applied. Waiting for green and it is ready to be merged. |
*/ | ||
private function createSubjectMapping($associationEntity, $subject, ClassMetadata $associationEntityMetadata) | ||
{ | ||
$subjectMapping = ['fieldName' => 'owner', 'targetEntity' => $associationEntity, 'inversedBy' => 'associations', 'joinColumns' => [['name' => $subject . '_id', 'referencedColumnName' => $associationEntityMetadata->fieldMappings['id']['columnName'], 'nullable' => false, 'onDelete' => 'CASCADE',]],]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be too long.
4eb76b4
to
0b92f1a
Compare
0b92f1a
to
a18726e
Compare
[Association] Associated products
Great work, thanks Łukasz and all reviewers! 👍 I will setup repositories later today. :) |
It is extended #2098 PR. @l3l0 has done awsome work so I only extracted it to separated bundle.
This PR was reviewed once, but feel free to point me out more problems ;)
Update
Important change
Due to extraction to different budnle the previous configuration does not apply any more.
Previous config:
After feedback it was decided to change a configuration to more dynamic. Current version is inspired by AttributesBundle configuration.
Now it has to be done in separated tree, where you have to precise a subject of association. The most basic config looks like that:
Because of assigning this PR to v0.16 milestone it was associated with @pamil #3110 PR
TODOs:
Update
Since last time I have worked on this PR plenty things changed in Sylius core, so new dynamic configuration has to be adjusted to them. For now, new association configuration looks like this: