UPSTREAM FIX

magento2-39690: Special price with a time in price_to is valid one day longer

Community fix magento2-39690 merged into magento/magento2 on 2025-07-02, released in 2.4.9; applies cleanly to 6 releases from 2.4.8 to 2.4.8-p5.

Special price with a time in price_to is valid one day longer edited

Pull request title
Special Price To Date is wrongly validated on applySpecialPrice
Pull request
magento/magento2#39690
Issues
#39169 human
Author
@KrasnoshchokBohdan
Merged
2025-07-02
Fixed in
2.4.9
Reported on
2.4.4-p7
Categories
—
Components
magento/framework, magento/module-bundle, magento/module-catalog

Labels

Area
APIs
Component
Api
Priority
P3
Severity
—
Reported on (labels)
2.4.4-p7

Issue

Title and steps come from the upstream issue and pull request.

Description

End date is missed and expire day after

Steps to reproduce

Use Rest API to set special price
/rest/default/V1/products/special-price

provide body like
{
  "prices": [
    {
      "price": 5,
      "store_id": 1,
      "sku": "1181",
      "price_from": "2024-08-02 17:00:00",
      "price_to": "2024-09-12 17:00:00",
      "extension_attributes": {}
    }
  ]
}
then check your price on front-end
admin or whatever

your special price will be visible until tomorrow 17

so instead expire at 2024-09-12 17:00:00 it will expire on 2024-09-13 17:00:00

because of validation on Magento\Catalog\Model\Product\Type\Price::calculateSpecialPrice
            if ($this->_localeDate->isScopeDateInInterval($store, $specialPriceFrom, $specialPriceTo)) {
                $finalPrice = min($finalPrice, (float) $specialPrice);
            }
instead of check in range from -> to
it add to end date 1 day

Magento\Framework\Stdlib\DateTime\Timezone::isScopeDateInInterval

maybe it can be used for other validation but for real not for calculateSpecialPrice it should be in range from -> to set by admin

Expected result

Product special price should expire on date set by admin or 3rd party system by REST API

Actual result

End date is missed and expire day after

Taken from the upstream issue.

Code match per tag

Each tag was checked with git apply --check against that tag's files. A clean match means the change applies; it is not a test result. Tags that already contain the fix are marked.

LineCode match per tagTests
2.4.6
2.4.6 conflict 2.4.6-p1 conflict 2.4.6-p2 conflict 2.4.6-p3 conflict 2.4.6-p4 conflict 2.4.6-p5 conflict 2.4.6-p6 conflict 2.4.6-p7 conflict 2.4.6-p8 conflict 2.4.6-p9 conflict 2.4.6-p10 conflict 2.4.6-p11 conflict 2.4.6-p12 conflict 2.4.6-p13 conflict 2.4.6-p14 conflict 2.4.6-p15 conflict
2.4.6: no test data 2.4.6-p1: no test data 2.4.6-p2: no test data 2.4.6-p3: no test data 2.4.6-p4: no test data 2.4.6-p5: no test data 2.4.6-p6: no test data 2.4.6-p7: no test data 2.4.6-p8: no test data 2.4.6-p9: no test data 2.4.6-p10: no test data 2.4.6-p11: no test data 2.4.6-p12: no test data 2.4.6-p13: no test data 2.4.6-p14: no test data 2.4.6-p15: no test data
2.4.7
2.4.7 conflict 2.4.7-p1 conflict 2.4.7-p2 conflict 2.4.7-p3 conflict 2.4.7-p4 conflict 2.4.7-p5 conflict 2.4.7-p6 conflict 2.4.7-p7 conflict 2.4.7-p8 conflict 2.4.7-p9 conflict 2.4.7-p10 conflict
2.4.7: no test data 2.4.7-p1: no test data 2.4.7-p2: no test data 2.4.7-p3: no test data 2.4.7-p4: no test data 2.4.7-p5: no test data 2.4.7-p6: no test data 2.4.7-p7: no test data 2.4.7-p8: no test data 2.4.7-p9: no test data 2.4.7-p10: no test data
2.4.8
2.4.8 clean 2.4.8-p1 clean 2.4.8-p2 clean 2.4.8-p3 clean 2.4.8-p4 clean 2.4.8-p5 clean
2.4.8: no test data 2.4.8-p1: no test data 2.4.8-p2: no test data 2.4.8-p3: no test data 2.4.8-p4: no test data 2.4.8-p5: test could not run before the patch, passes afterunit: could not run before, passes after
2.4.9
2.4.9 conflictcontains the fix
2.4.9: no test data

Triage

Model @cf/cloudflare/clef. Probability this is a bug fix: 97.4%. Probability it is security relevant: 0.6%.

Show the model's answers and probabilities
QuestionAnswerProbabilitiesConfidence
Change kindbugfixbugfix 95.0%, refactor 2.5%, tests_only 1.0%, feature 0.8%, dependency 0.4%, docs_only 0.4%88.4%
Areacatalogcatalog 51.0%, framework 21.1%, graphql_api 15.9%23.9%
Reported version2.4.4-p72.4.4-p7 57.6%, 2.4.4 4.3%, 2.4.4-p6 1.0%32.7%
Scope1.48 of 22 57.9%, 1 32.1%, 0 10.0%17.3%
Risk1.48 of 22 60.5%, 1 26.9%, 0 12.6%18.2%
Worth backporting1.33 of 22 45.5%, 1 42.3%, 0 12.2%10.2%

Download

For cweagans/composer-patches, choose a version below and download the bundle. Copy its magento2-39690/ folder into patches/composer/, merge composer.patches.json into composer.json, then run composer install. Test files are always removed; paths are relative to each package root, using the default -p1 level.

Packages (3): magento/module-bundle, magento/module-catalog, magento/framework
Bundle README (what the ZIP ships)
# magento2-39690

Community fix merged upstream into magento/magento2, adapted by magento.watch.
This is not a patch published by Adobe.

Pull request: https://github.com/magento/magento2/pull/39690
Issue: https://github.com/magento/magento2/issues/39169
Author: @KrasnoshchokBohdan
Source commit: bd6ef727bea8e531ba26aad079c03fefad48e949
Modifications: test files and documentation removed, paths rewritten relative to each Composer package.
Licence: OSL-3.0 / AFL-3.0, as the original Magento Open Source code.
Maintainer: Łukasz Bajsarowicz (@lbajsarowicz)

Licence: Magento Open Source code under OSL-3.0 and AFL-3.0. The bundle carries the original author, source commit and the list of modifications.

Sources

Łukasz Bajsarowicz
Built by

Łukasz Bajsarowicz, e-commerce architect

Magento and Adobe Commerce architecture, upgrades, performance and audits for merchants and agencies since 2015; magento.watch is the tooling I use on those projects.

Open source, maintained on weekends.