I need the date of out of stock product.
is this possible we get the date of product when the product is out of stock or again quantity added in stock?
Thanks.
I get the date of out of stock products in column low_stock_date
of this table cataloginventory_stock_item
from databse.
Here is the query:
SELECT cataloginventory_stock_item.product_id, cataloginventory_stock_item.low_stock_date, catalog_product_entity.sku FROM cataloginventory_stock_item INNER JOIN catalog_product_entity ON (cataloginventory_stock_item.product_id= catalog_product_entity.entity_id AND cataloginventory_stock_item.qty= 0 AND (cataloginventory_stock_item.low_stock_date BETWEEN '2017-12-19 00:00:01' AND '2017-12-19 23:59:59'))
i get product id, SKU and date of out of stock product by above query.
And in Magento way:
$collection = Mage::getModel('catalog/product')
->getCollection()->addAttributeToSelect('*');
foreach($collection as $product){
$productid = $product->getId();
$productsku = $product->getSku();
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getIsInStock();
$lowstockdate = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getLowStockDate();
if($stock == 0 ){
echo $product->getSku()." = ";
echo $product->getName()." = ";
echo $lowstockdate."<br>";
}
}