Skip to content

Commit 7274ed1

Browse files
#39959 catalog_product_save_before observer throws date-related 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.
1 parent c8ba4ab commit 7274ed1

File tree

1 file changed

+7
-1
lines changed
  • app/code/Magento/Catalog/Model/Product/Type

1 file changed

+7
-1
lines changed

app/code/Magento/Catalog/Model/Product/Type/Price.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,16 @@ protected function _getCustomerGroupId($product)
451451
*/
452452
protected function _applySpecialPrice($product, $finalPrice)
453453
{
454+
455+
$specialPriceFrom = $product->getSpecialFromDate();
456+
if ($specialPriceFrom instanceof \DateTimeInterface) {
457+
$specialPriceFrom = $specialPriceFrom->format('Y-m-d H:i:s');
458+
}
459+
454460
return $this->calculateSpecialPrice(
455461
$finalPrice,
456462
$product->getSpecialPrice(),
457-
$product->getSpecialFromDate(),
463+
$specialPriceFrom,
458464
$product->getSpecialToDate(),
459465
WebsiteInterface::ADMIN_CODE
460466
);

0 commit comments

Comments
 (0)