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
[CatalogPromotion][API][UI] Fixed discount action #13325
[CatalogPromotion][API][UI] Fixed discount action #13325
Conversation
GSadee
commented
Nov 24, 2021
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Related tickets | |
License | MIT |
src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionActionTypeExtension.php
Show resolved
Hide resolved
835dbf6
to
3478fe3
Compare
...otion/applying_catalog_promotions/applying_all_available_types_of_catalog_promotions.feature
Outdated
Show resolved
Hide resolved
...n/applying_catalog_promotions/applying_catalog_promotions_with_fixed_discount_action.feature
Outdated
Show resolved
Hide resolved
...atalog_promotions/applying_catalog_promotions_with_taking_minimum_price_into_account.feature
Outdated
Show resolved
Hide resolved
features/promotion/managing_catalog_promotions/creating_catalog_promotion.feature
Outdated
Show resolved
Hide resolved
src/Sylius/Behat/Context/Api/Admin/ManagingCatalogPromotionsContext.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/spec/Calculator/FixedDiscountPriceCalculatorSpec.php
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/spec/Calculator/PercentageDiscountPriceCalculatorSpec.php
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/spec/Calculator/PercentageDiscountPriceCalculatorSpec.php
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Form/Type/CatalogPromotionActionType.php
Outdated
Show resolved
Hide resolved
public function validate($value, Constraint $constraint): void | ||
{ | ||
/** @var CatalogPromotionAction $constraint */ | ||
Assert::isInstanceOf($constraint, CatalogPromotionAction::class); | ||
|
||
/** @var CatalogPromotionActionInterface $value */ | ||
if ($value->getType() !== CatalogPromotionActionInterface::TYPE_PERCENTAGE_DISCOUNT) { | ||
if (!in_array($value->getType(), $this->actionTypes, true)) { |
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.
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 true, it looks the same with validators for scopes. What is your suggestion? The simplest one is probably to have a separate parameter that is an array of these types 🤔
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 parameter would be a good improvement. However, going deeper what would you say, that these consts would be defined by calculators themselves? Then we could tag them and use their const as a tag attribute and here use another tag iterator. Going further, we could define expectations for static method with the name, but I'm not sure if it makes sense to introduce it day before the end of sprint
ref. https://symfony.com/doc/current/service_container/tags.html#tagged-services-with-index
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'm 👌🏻 for refactoring, but I would be for making it in a separate PR for both actions and scopes
fcd8898
to
50c9270
Compare
…new fixed discount action
…ew fixed discount action
ea5c411
to
f056098
Compare
f056098
to
969595a
Compare
Thanks, Grzegorz! 🥇 |
…tion on catalog show page (GSadee) This PR was merged into the 1.11 branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | 1.11 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | fixes #13325 | License | MIT <!-- - Bug fixes must be submitted against the 1.10 or 1.11 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 ------- 98c7cd3 [CatalogPromotion][Admin] Fix displaying fixed discount action on catalog show page
…reating a custom action + minor improvements (GSadee) This PR was merged into the 1.11 branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | 1.11 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | partially fixes ##13325 (comment) | License | MIT This PR contains a minor refactor of parameters with types of actions/scopes passed to validators. <!-- - Bug fixes must be submitted against the 1.10 or 1.11 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 ------- 7f33db6 [CatalogPromotion] Create parameters with collections of scopes and actions types 08e9a0c [Documentation][CatalogPromotion] Add cookbook about creating a custom action c4816cd [Documentation][CatalogPromotion] Minor improvements to cookbook about creating a custom scope e45593d [Documentation][CatalogPromotion] Fixes to cookbooks about creating custom action and scope