-
Notifications
You must be signed in to change notification settings - Fork 4
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
Implement "bought together products" #7
Implement "bought together products" #7
Conversation
<argument type="service" id="doctrine.orm.entity_manager" /> | ||
<argument type="service" id="sylius.repository.product" /> | ||
<argument type="service" id="CommerceWeavers\SyliusAlsoBoughtPlugin\Provider\BoughtTogetherProductsAssociationProviderInterface" /> | ||
<argument>10</argument> |
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.
Would be nice to parametrize it.
foreach ($order->getItems() as $item) { | ||
$productCode = $item->getProduct()?->getCode(); |
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.
Since items are created from variants, wouldn't we potentially have a lot of wasteful processing cause $productCode
can be inserted multiple times within $productCodes
, but the foreach below will simply overwrite the key on each run w/ $map[$productCode] = array_diff($productCodes, [$productCode])
?
If the duplicates are needed for the value it might be worth making another array with unique codes and iterate over that instead.
@@ -0,0 +1,19 @@ | |||
Copyright (c) 2023-2077 Commerce Weavers |
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.
Just curious, what's the legality here?
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.
Personally don't know, just copied from https://github.com/CommerceWeavers/SyliusSaferpayPlugin/blob/main/LICENSE.md 😄
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.
💃
); | ||
} | ||
|
||
public function testItProvidesEarliestPossibleDateIfThereIsNoSynchronizationLog(): void |
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.
That's just wrong, it returns current not the earliest possible
This plugin was sponsored by [Mofakult](https://www.mofakult.ch) | ||
and developed in cooperation with [Fusonic](https://www.fusonic.net). | ||
Thank you for your contribution to the open-source ecosystem! |
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.
Would be nice to put Mofakult and Fusonic logos somewhere here 💃
<service id="CommerceWeavers\SyliusAlsoBoughtPlugin\Cli\CreateBoughtTogetherProductAssociationTypeCommand"> | ||
<argument type="service" id="Symfony\Component\Messenger\MessageBusInterface" /> | ||
<argument type="service" id="sylius.repository.product_association_type" /> | ||
<tag name="console.command" /> |
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 wonder, that maybe we can move forward with autowiring and autoconfiguration for our plugins 🤔 but could be done separately
And the store has a product association type "Bought together" with a code "bought_together" | ||
When I create a bought together product association type by running command | ||
Then I should be informed that the bought together product association type already exists | ||
|
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.
Extra blank line 🚀
@cli | ||
Scenario: Running setup bought together command when there is no bought together product association type | ||
Given the store operates on a single channel in "United States" | ||
When I create a bought together product association type by running command |
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.
by running command
is an implementation details, should be removed
Feature: Creating bought together product association type | ||
In order to setup plugin | ||
As a Developer | ||
I want to run a command that will create bought together product association type |
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 want to create bought together product association type
? To focus on business value not on the details
'commerce_weavers_sylius_also_bought_plugin', | ||
'doctrine/orm', |
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.
Let's extract those values to constants
private Uuid $id, | ||
private \DateTimeImmutable $date, | ||
private int $numberOfOrders, | ||
private array $affectedProducts, |
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.
Could be readonly
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.
Oh, it cannot be, because we're supporting still PHP 8.0 💃 We could bump to 8.1 at least
|
||
namespace CommerceWeavers\SyliusAlsoBoughtPlugin\Exception; | ||
|
||
class BoughtTogetherAssociationTypeNotFoundException extends \RuntimeException |
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.
Could be final
if (null === $lastSynchronization) { | ||
return (new \DateTimeImmutable())->setTimestamp(0); | ||
} |
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 agree 👍
|
||
|
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.
Doubled blank line 💃
Thank you, Kevin, amazing work! 🎉 |
The class 'Tests\CommerceWeavers\SyliusAlsoBoughtPlugin\Application\Entity\Product' was not found in the chain configured namespaces
)GreetingController
@api
and@ui