- Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Area: CatalogComponent: CatalogIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.May be fixed according to the position in the backlog.Progress: doneReported on 2.4.6-p10Indicates original Magento version for the Issue report.Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject itIssue related to Developer Experience and needs help with Triage to Confirm or Reject it
Description
Preconditions and environment
- Magento 2.4.6-p10 (Community Edition)
- Custom extension using catalog_product_save_before observer
- Using REST API: POST /rest/default/V1/products
Steps to reproduce
- Create a custom module with an observer for
catalog_product_save_before
. - Inside the observer, call
$product->getFinalPrice()
. - Save a product using REST API: POST /rest/default/V1/products
- Use the following JSON payload (no store-level pricing):
{ "product": { "sku": "testing-special-date", "price": 120, "status": 0, "visibility": 4, "type_id": "simple", "extension_attributes": { "stock_item": { "stock_id": 1, "qty": 207, "is_in_stock": true } }, "custom_attributes": [ { "attribute_code": "tax_class_id", "value": "2" }, { "attribute_code": "special_price", "value": "100.00" } ] }, "saveOptions": true }
Testing.Special.Date._.Products._.Inventory._.Catalog._.Magento.Admin.mp4
Expected result
- The product is saved successfully.
- $product->getFinalPrice() returns the correct final price or null without error.
Actual result
- A date-related error is thrown during the API call.
- The error occurs inside the observer when
$product->getFinalPrice()
is invoked. - The issue does not happen if the same product is saved via Admin panel.
Additional information
- The issue seems related to store scope context missing or pricing attributes being incomplete in API context.
- It may be caused by Magento trying to calculate special price without required store-level values.
- The same observer logic works when the product is saved via Admin.
Temporary Workaround:
- Avoid using
$product->getFinalPrice()
incatalog_product_save_before
for API calls. - Use
$product->getData('final_price')
or defer final price logic until after save.
Release note
When saving a product using the REST API, and calling $product->getFinalPrice()
inside the catalog_product_save_before
observer, a date-related error is thrown if store-level values like special_price
are not defined.
This works as expected when saving the product via the Magento Admin panel.
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Area: CatalogComponent: CatalogIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.May be fixed according to the position in the backlog.Progress: doneReported on 2.4.6-p10Indicates original Magento version for the Issue report.Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject itIssue related to Developer Experience and needs help with Triage to Confirm or Reject it