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

[CatalogPromotions] Take into account CP dates during processing #13189

Conversation

Zales0123
Copy link
Member

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets
License MIT

Based on the work from this PR, we can start taking into account catalog promotion dates during their processing. Initially, I assumed that all CatalogPromotionInterface $catalogPromotion arguments passed to CatalogPromotionProcessor::process will be already eligible (as we only use this processor in the AllCatalogPromotionsProcessor service. If in the future, we will need filtration other than on CPs collection (e.g. on a single catalog promotion), we can extend the filter's functionality 🖖

Note: I wanted to use a calendar service that is already used in Behat... but it's implemented in the ShippingBundle 💃 probably we would need to extract it somewhere to make it available for all other date-/time-based functionalities.

@Zales0123 Zales0123 added the Feature New feature proposals. label Oct 11, 2021
@Zales0123 Zales0123 requested a review from a team as a code owner October 11, 2021 05:24
@Zales0123 Zales0123 changed the title [Behat] Describe CP time ranges with Behat scenarios [CatalogPromotions] Take into account CP dates during processing Oct 11, 2021
@Zales0123 Zales0123 force-pushed the include-start-and-end-date-into-catalog-promotion-processing branch from 34955d3 to d328e8f Compare October 11, 2021 05:29
And I should see this product has no catalog promotion applied

@api @ui
Scenario: Not applying catalog promotion if its end date has alread passed
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
Scenario: Not applying catalog promotion if its end date has alread passed
Scenario: Not applying catalog promotion if its end date has already passed

return $this->catalogPromotionRepository->findAll();
}

return array_values($this->catalogPromotionRepository->findByCriteria($criteria));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why array_values()?

public function provide(iterable $criteria = []): iterable
{
if (empty($criteria)) {
return $this->catalogPromotionRepository->findAll();
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be just:

return $this->catalogPromotionRepository->findByCriteria($criteria);

Cause that repo method has foreach so empty array will not add any where call etc. & in fact will do same as findAll().

/**
* @param iterable|CriteriaInterface[] $criteria
*
* @return iterable|CatalogPromotionInterface[]
Copy link
Contributor

Choose a reason for hiding this comment

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

More accurate would be saying:

Suggested change
* @return iterable|CatalogPromotionInterface[]
* @return array<int, CatalogPromotionInterface>

@GSadee GSadee merged commit 39ec97f into Sylius:master Oct 11, 2021
@GSadee
Copy link
Member

GSadee commented Oct 11, 2021

Thanks, Mateusz! 🎉

Zales0123 added a commit that referenced this pull request Oct 11, 2021
…PromotionsProvider (GSadee)

This PR was merged into the 1.11-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | fixes after comments from #13189
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.9 or 1.10 branch (the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->


Commits
-------

5fb30cd [CatalogPromotion] Minor improvements in EligibleCatalogPromotionsProvider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature proposals.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants