-
Notifications
You must be signed in to change notification settings - Fork 33
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
Bugfix(PricingRules): Prevent Error when adding a new Pricing Rule with a name that exists #214
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
recheck |
src/PricingManager/Rule/Dao.php
Outdated
$this->db->beginTransaction(); | ||
if (!$this->model->getId()) { | ||
$this->create(); | ||
} | ||
|
||
$this->update(); | ||
$this->db->commit(); |
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.
Shouldn't we also rollback on error?
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.
Yes sure - added the rollback
$this->update(); | ||
$this->update(); | ||
$this->db->commit(); | ||
} catch (\Exception $e) { |
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.
Can you please import the Exception instead of using the global namespace?
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.
I know, but improving bit by bit also works :)
In other bundles we already have CS Fixer Rules in place, but it's only a small change so I will do it quickly :)
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 you also please rebase the PR to 1.2 since it is a bugfix?
…tal (#200) * Set amount to the subtotal when the discount amount exceeds the subtotal * Make not discounting price modifications optional * Remove deprecation
* [WIP] Initial opensearch draft * Apply php-cs-fixer changes * Indexing works with opensearch * add small cleanup * add small cleanup * Check productlisting with opensearch tenant * Apply php-cs-fixer changes * Replace elastic search everywhere * add more cleanup * add more cleanup * add more cleanup * add original sync command * remove debug * Apply php-cs-fixer changes * Add deprecations and duplicate filtertypes for opensearch * Apply php-cs-fixer changes * Add docs for OpenSearch * Apply php-cs-fixer changes * Add to ignore 404 on create-index * Apply php-cs-fixer changes * fix: ignore 404 as we handle it differently * fix: ignore 404 as we handle it differently * Prepare groups for multi select --------- Co-authored-by: mattamon <[email protected]> Co-authored-by: lukmzig <[email protected]> Co-authored-by: lukmzig <[email protected]>
…th a name that exists When you create a Pricing Rule with an name that already exists the backend interface is not loading the pricing rules anymore because it inserts a row with "null" values. The reason is because the create() call is successfully but at the update() call you get an errror because a pricing Rule with that name already exists. Solution -> wrap it into a transaction
f57131c
to
7bda5e2
Compare
…tal (#200) * Set amount to the subtotal when the discount amount exceeds the subtotal * Make not discounting price modifications optional * Remove deprecation
* [WIP] Initial opensearch draft * Apply php-cs-fixer changes * Indexing works with opensearch * add small cleanup * add small cleanup * Check productlisting with opensearch tenant * Apply php-cs-fixer changes * Replace elastic search everywhere * add more cleanup * add more cleanup * add more cleanup * add original sync command * remove debug * Apply php-cs-fixer changes * Add deprecations and duplicate filtertypes for opensearch * Apply php-cs-fixer changes * Add docs for OpenSearch * Apply php-cs-fixer changes * Add to ignore 404 on create-index * Apply php-cs-fixer changes * fix: ignore 404 as we handle it differently * fix: ignore 404 as we handle it differently * Prepare groups for multi select --------- Co-authored-by: mattamon <[email protected]> Co-authored-by: lukmzig <[email protected]> Co-authored-by: lukmzig <[email protected]>
…th a name that exists When you create a Pricing Rule with an name that already exists the backend interface is not loading the pricing rules anymore because it inserts a row with "null" values. The reason is because the create() call is successfully but at the update() call you get an errror because a pricing Rule with that name already exists. Solution -> wrap it into a transaction
…th a name that exists When you create a Pricing Rule with an name that already exists the backend interface is not loading the pricing rules anymore because it inserts a row with "null" values. The reason is because the create() call is successfully but at the update() call you get an errror because a pricing Rule with that name already exists. Solution -> wrap it into a transaction
I shomehow destroyed my fork with trying to rebase this. |
This reverts commit 8806162.
…th a name that exists (#216) * Bugfix Pricing Rules -> #214 * Revert "Bugfix Pricing Rules -> #214" This reverts commit 8806162. * fix copy paste error * Update src/PricingManager/Rule/Dao.php Co-authored-by: Jacob Dreesen <[email protected]> --------- Co-authored-by: Jacob Dreesen <[email protected]>
When you create a Pricing Rule with an name that already exists in the backend, a invalid Database entry is added. Therefore the admin interface is not loading the pricing rules anymore.
The reason is because the create() call is successfully but in the update() call you get an error because a pricing Rule with that name already exists. Solution -> wrap it into a transaction so both queries have to be executed successfully