Tier price removal in CRON job using wrong website context
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 12.2k
- Forks
- 9.4k
- PR merge metrics
- No merged PRs in 30d
Description
### Preconditions and environment
M2.4.1
ScopedTierPrice (on this [line](https://github.com/magento/magento2/blob/7c6b6365a3c099509d6f6e6c306cb1821910aab0/app/code/Magento/Catalog/Model/Product/ScopedTierPriceManagement.php#L147)) calls `getWebsiteId` aiming to get current website of the context of currently running application. If you run this from CRON the website ID ends up with 0 (as there is Admin set as fallback) and the current removal throws exception. The mentioned line should consider the current tierPrice website and use it as a context.
### Steps to reproduce
Price scope set to website
1. run code from CRON
2. fetch list of tier prices for any product
3. try to remove them with scoped tier management
### Expected result
Tier price is removed
### Actual result
Exception is thrown stating given tier price doesn't exist (which is actually correct - tier price for website ID 0 normally really doesn't exit)
### Additional information
_No response_
### Release note
_No response_
### 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._
- [X] 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”._
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in app/code/Magento/Catalog/Model/Product/ScopedTierPriceManagement.php at the getWebsiteId call on line 147. Reproduce the removal flow from CRON with website-scoped prices, then verify that removing fetched tier prices succeeds without the missing-price exception and that the existing website context is respected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100