Skip to content

ProductAlert for out of stock not working #1699

Closed
@Ingvar1917

Description

@Ingvar1917

What I do:

  1. subscribe to a product is not in stock
  2. change inventory to "in stock", and start reindex (bin/magento indexer:reindex)
  3. run cron, make sure the load observer app/code/Magento/ProductAlert/Model/Observer.php::process()
    actual result - the message is not sent

I think the problem with the following code

app/code/Magento/CatalogInventory/Model/StockRegistry.php

public function getStockStatus($productId, $websiteId = null)
{
  //if (!$websiteId) {
    $websiteId = $this->stockConfiguration->getDefaultWebsiteId();
  //}
    return $this->stockRegistryProvider->getStockStatus($productId, $websiteId);
}

debug case:

public function getStockStatus($productId, $websiteId = null) // $websiteId == 1
{
  //if (!$websiteId) {
    $websiteId = $this->stockConfiguration->getDefaultWebsiteId(); $websiteId == 0
  //}
    return $this->stockRegistryProvider->getStockStatus($productId, $websiteId);
}

if remove commented code, the message is sent.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentbug report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions