-
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
.
…d error when using REST API without store-level values (getFinalPrice() issue) Add tests and logic for handling special_from_date updates Introduced integration and unit tests to validate behavior of the special price start date logic. Ensures special_from_date is set automatically if not provided and remains unchanged when already set. Also added comments and adjustments to observer logic to handle special price updates consistently.
@magento run Integration Tests, Unit Tests, Static Tests |
@magento run all tests |
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 (*)