February 27, 2020

cm-mini

Thinking Magento

Magento - Low Stock Notifications

Stock notifications in Magento are always confusing and it seems to me like the issue needs to be cleared up for some. Stock notification on the frontend of the store is for the customer to know when a product is back in stock. They will be alerted by an email that is sent when triggered by the cronjob in the early hours. The other is the RSS feed that can be found on the Catalog > Manage Products grid. This particular RSS feed however is admin protected, which in theory would be great, but in reality can be a real pain. I'll explain in this blog how to utilise the RSS feed, as well as the Low Stock Grid and a few other tips on how to manage your stock levels.

First of all you are going to require making some core hacks, you could modulise this, however for all intensive purposes the following will be surfice.

Open up /app/code/core/Mage/Rss/controllers/CatalogController.php

and remove  Mage::helper('rss')->authAdmin('catalog/products'); from public function notifystockAction().

This will remove the login authentication from the Low Product Stock RSS feed.

You can then use website like Feed My Inbox to check the RSS feed daily and to email your account once stock has reached 0. This then removes any need for tedious RSS viewers or readers to be running in your browser or desktop and that each morning the is the possibility of a stock notifcation.

On top of this method, the Low Stock Grid in the Reports section of Magento is extremely valuable.

Again though some alterations are required in order to fix the problems.

First of all if your on a version of Magento that is lower than 1.4.0.1 and you do not want to upgrade, however you are unable to filter by Qty on your Low Stock Grid, then all you need to do is download a copy of Magento 1.4 and find file app/code/core/Mage/Reports/Model/Mysql4/Product/Lowstock/Collection.php. You can use this file to replace the one you are currently using on your installation. We've posted in the Magento forums exactly what the problem is for this fix.

Next up is to give your Low Stock Grid more functionality and you can do this by adding in another column called Low Stock Date. This will allow you to filter when products went out of stock, depending on what number your low stock notification is set to.

For this we need make a copy of 

app/code/core/Mage/Adminhtml/Block/Report/Product/Lowstock/Grid.php

and place it in the same set for directories within /code/local 

->joinInventoryItem('qty')
with
->joinInventoryItem('qty')
->joinInventoryItem('low_stock_date')
and then further down add to the columns
 
$this->addColumn('low_stock_date', array(
'header' =>Mage::helper('reports')->__('Low Stock Date'),
'sortable' =>false,
'index' =>'low_stock_date',
'type' =>'date'
 ));
This will now give you a new column of when Low Stock was reported in the Magento system.

IF selling products via the admin and going into minus levels of stock, the Low Stock Date will update to the day of the most recent order with the associated product.
 
* Make backups of all core files before making changes.