-
Notifications
You must be signed in to change notification settings - Fork 9.4k
magento/magento2#39959 catalog_product_save_before observer throws date-related error when using REST API without store-level values (getFinalPrice() issue) #40003
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
base: 2.4-develop
Are you sure you want to change the base?
Conversation
…d error when using REST API without store-level values (getFinalPrice() issue) Adjusted the processing of `SpecialFromDate` to ensure proper formatting when the date is provided as a `DateTimeInterface` instance. This prevents errors arising during `getFinalPrice()` execution under certain scenarios.
Hi @KrasnoshchokBohdan. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
@magento run all tests |
…d error when using REST API without store-level values (getFinalPrice() issue) Updated special price logic to ensure date formats are handled consistently when calculating and setting the "special from" date. This improves compatibility and prevents potential type issues with date-related operations.
@magento run all tests |
…d error when using REST API without store-level values (getFinalPrice() issue) - fix static test errors
@magento run all tests |
@magento run Unit 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.
Hello @KrasnoshchokBohdan,
Thanks for the contribution!
The changes seems good to us, but some suggestion as follows:
- The PR changes can be covered by unit and integration tests. A test should verify that setting a special price via API or admin behaves correctly.
- Add inline comments to explain the rationale behind formatting
special_from_date
.
Adjusted the processing of
SpecialFromDate
to ensure proper formatting when the date is provided as aDateTimeInterface
instance. This prevents errors arising duringgetFinalPrice()
execution under certain scenarios.Description (*)
I focused on investigation error

TypeError: strtotime(): Argument #1 ($datetime) must be of type string, DateTime given in lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php:275
the reason for it must be
\Magento\Catalog\Observer\SetSpecialPriceStartDate::execute
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
payload
Questions or comments
Contribution checklist (*)