magento2: AlertProcessor - Argument #2 ($storeId) must be of type int, string given
Preconditions and environment
- Magento version 2.4.4
- PHP8.1
Steps to reproduce
- Enable product alert stock in BO (Configuration > Catalog >Product Alerts > Allow Alert When Product Comes Back in Stock > Yes, Allow Alert When Product Price Changes - Yes)
- Reindex and cache flush
- Front end - Login as customer - Select a Product without stock - Register to a product stock alert (Notify me when the price drops, Notify me when this product is in stock)
- Add stock to that product from admin
- Launch consumers
Expected result
Alert stock email being sent
Actual result
Emails not triggered for Product Alerts
[2022-06-10T07:31:56.520650+00:00] .CRITICAL: Magento\ProductAlert\Model\Mailing\ErrorEmailSender::execute(): Argument #2 ($storeId) must be of type int, string given, called in /var/www/html/vendor/magento/module-product-alert/Model/Mailing/AlertProcessor.php on line 130 [] []
Additional information
I guess (not tested) that change could solve the issue
Magento\Store\Model\Store
ACTUAL CODE
/**
* Get store identifier
*
* @return int
*/
public function getId()
{
return $this->_getData(self::STORE_ID);
}
PROPOSED FIX
/**
* Get store identifier
*
* @return int
*/
public function getId(): int
{
return (int) $this->_getData(self::STORE_ID);
}
(of course, StoreInterface interface should be modified accordingly.)
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.
- 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”.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 17 (4 by maintainers)
Commits related to this issue
- Issue #35602 getId() return type was updated from string to int as per documentation — committed to artskirk/magento2-1-fork by deleted user 2 years ago
- Issue #35602 code fix — committed to artskirk/magento2-1-fork by deleted user 2 years ago
- Issue #35602 add Unit test — committed to artskirk/magento2-1-fork by deleted user 2 years ago
- Issue #35602 Add Unit test fixes — committed to artskirk/magento2-1-fork by deleted user 2 years ago
In case anybody stumbles upon this issue, the store id type is only coming up when trying to send an error email caused by another error in the
getFilteredContentfunction. The following patch applies a self-contained fix for both, is can be applied directly tomagento/module-product-alert.Hi @Nuranto
The issue is still reproducible. So reopening the ticket again.
Thanks.
Why did this issue got closed? @katmoon: do you have an explanation? Can you link to some commits that fixed it?