Skip to content

low stock report with MSI does not show products with 0 stock – need to override resourcemodel?

I have 2 sources and I have set up for each important product a notify stock level in order to have a list of what to restock.

Products in each sources with a stock level below the notify level show up fine. But if that stock goes to 0, they no longer show in the report.

So if a product goes from above warning level straight to 0, it will not show on the list and that means if you have fast shifting stock the report is of no use operationally.

if I have a stock notification level set at 6 and my product goes to 0, I need this to appear!

UPDATE THIS IT SEEMS IS HARD CODED IN (WHY????)

Details

in InventoryLowQuantityNotificationModelResourceModelLowQuantityCollection.php

private function addSourceItemInStockFilter(): void
    {
        $condition = '(' . SourceItemInterface::QUANTITY . ' > 0 AND main_table.status = ' .
            SourceItemInterface::STATUS_IN_STOCK . ')';
        $this->getSelect()->where($condition);
    }

I gather I now need to override that resourcemodel but so much of it is private/protected it could be a minefield?

I think it probably would be best to override _renderFilters

protected function _renderFilters()
{
    if (false === $this->_isFiltersRendered) {
        $this->joinInventoryConfiguration();
        $this->joinCatalogProduct();

        $this->addProductTypeFilter();
        $this->addNotifyStockQtyFilter();
        $this->addEnabledSourceFilter();
        $this->addSourceItemInStockFilter();
        $this->addSourceItemStoreFilter();
    }
    return parent::_renderFilters();
}

I’ll leave this here as I’m sure I’ll fail utterly by tomorrow to write code that works and someone will be able to help.