[CatalogPromotions] Take into account CP dates during processing#13189
Merged
GSadee merged 5 commits intoOct 11, 2021
Merged
Conversation
34955d3 to
d328e8f
Compare
GSadee
approved these changes
Oct 11, 2021
| 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 |
Member
There was a problem hiding this comment.
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 |
stloyd
reviewed
Oct 11, 2021
| return $this->catalogPromotionRepository->findAll(); | ||
| } | ||
|
|
||
| return array_values($this->catalogPromotionRepository->findByCriteria($criteria)); |
| public function provide(iterable $criteria = []): iterable | ||
| { | ||
| if (empty($criteria)) { | ||
| return $this->catalogPromotionRepository->findAll(); |
Contributor
There was a problem hiding this comment.
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[] |
Contributor
There was a problem hiding this comment.
More accurate would be saying:
Suggested change
| * @return iterable|CatalogPromotionInterface[] | |
| * @return array<int, CatalogPromotionInterface> |
Member
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 $catalogPromotionarguments passed toCatalogPromotionProcessor::processwill be already eligible (as we only use this processor in theAllCatalogPromotionsProcessorservice. 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.