Skip to content
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

Configure number of synchronised products in Channel configuration #32

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Zales0123
Copy link
Member

@Zales0123 Zales0123 commented Apr 9, 2024

Closes #22

TODO:

  • document that the highest number from channels would be used

Copy link
Member

@NoResponseMate NoResponseMate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess we're missing validation for the number_of_synchronised_products on the channel.

@@ -32,7 +33,12 @@ public function __invoke(SynchronizationEnded $event): void
Assert::allIsInstanceOf($products, BoughtTogetherProductsAwareInterface::class);

foreach ($products as $product) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there can be a lot of products, it would be nice to flush every x products besides the one after all.

$numberOfProducts = max($numberOfProducts, $channel->getNumberOfSynchronisedProducts());
}

if ($numberOfProducts === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($numberOfProducts === 0) {
if ($numberOfProducts <= 0) {

Covering an edge case

@@ -5,3 +5,8 @@ sylius_ui:
commerce_weavers_sylius_also_bought_missing_configuration:
template: '@CommerceWeaversSyliusAlsoBoughtPlugin/_missing_configuration.html.twig'
priority: 40
sylius.admin.channel.form.second_column_content:
blocks:
commerce_weavers_sylius_also_bought_number_of_synchronised_products:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
commerce_weavers_sylius_also_bought_number_of_synchronised_products:
commerce_weavers_sylius_also_bought_number_of_synchronized_products:

just because in different places, we already use the US version with z

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for twig tempalte file name etc.

@@ -0,0 +1,22 @@
@managing_channels
Feature: Managing number of items on channel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not detailed enough IMHO. I'd specify which items eg. Managing number of items to synchronize on channel

{
/** @ORM\Column(name="number_of_synchronised_products", type="integer", nullable=false, options={"default": 10}) */
#[ORM\Column(name: 'number_of_synchronised_products', type: 'integer', nullable: false, options: ['default' => 10])]
private int $numberOfSynchronisedProducts = 10;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private int $numberOfSynchronisedProducts = 10;
private int $numberOfSynchronizedProducts = 10;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move configuration of number of also bought products to the Channel configuration
3 participants