-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Scheduled price rule time zone correction #28973
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
Scheduled price rule time zone correction #28973
Conversation
Hi @AntonEvers. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. |
@magento run all tests |
1 similar comment
@magento run all tests |
@magento run all tests |
@magento create issue |
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.
Please, cover your changes with any kind of automated tests.
$sortOrder = (int)$rule->getSortOrder(); | ||
$actionOperator = $rule->getSimpleAction(); | ||
$actionAmount = $rule->getDiscountAmount(); | ||
$actionStop = $rule->getStopRulesProcessing(); | ||
|
||
$rows = []; | ||
foreach ($websiteIds as $websiteId) { | ||
$scopeTz = new \DateTimeZone( |
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.
Please, use framework TimeZone and DateTime object instead of generic PHP.
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 have removed the entire method, as it appears to be duplicate code. Instead I have done this: https://github.com/magento/magento2/pull/28973/files#r474752002
} | ||
|
||
$this->reindexRuleGroupWebsite->execute(); | ||
$this->doReindexByIds([$id]); |
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.
This is the main change in this file, the rest is removal of unused private methods (containing also duplicate code) after this change and adding of imports.
@magento run all tests |
Hi, @AntonEvers could you please merge conflict and cover changes with the automated tests? |
# Conflicts: # app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@magento run all tests |
@magento run all tests |
@magento run all tests |
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.
Further investigation discovered that the previous comment #28973 (review) is actually the Expected behavior ✔️ QA Passed Manual testing scenario
|
Hi @AntonEvers, thank you for your contribution! |
Description (*)
Apply the same logic for time zone correction on
\Magento\CatalogRule\Model\Indexer\IndexBuilder::assignProductToRule
as in\Magento\CatalogRule\Model\Indexer\ReindexRuleProduct::execute
.The problem here is that Magento 2.3 uses the method
\Magento\CatalogRule\Model\Indexer\IndexBuilder::assignProductToRule
. In Magento 2.4 this method is no longer used, but it is also not deprecated. So we can expect customers to use this method through the@api
method\Magento\CatalogRule\Model\Indexer\IndexBuilder::reindexById
. So even though the code in this PR is not used anywhere in vanilla M2.4, it is an@api
method that could result in catalog rules starting and ending at wrong time which is equal to the configured timezone offset.Applying this PR makes sure that time zones are applied equally in
\Magento\CatalogRule\Model\Indexer\IndexBuilder::reindexById
as they are in\Magento\CatalogRule\Model\Indexer\IndexBuilder::reindexByIds
. Currently they differ.Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
SELECT DISTINCT from_time, to_time FROM catalogrule_product;
bin/magento reindex:product 10
SELECT DISTINCT from_time, to_time FROM catalogrule_product;
Questions or comments
\Magento\CatalogRule\Model\Indexer\IndexBuilder::assignProductToRule
and\Magento\CatalogRule\Model\Indexer\ReindexRuleProduct::execute
do contain duplicate code. Maybe, after approving this PR, it would be worth while to deprecate or merge some of the methods.Contribution checklist (*)
Resolved issues: