0

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.

1

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>";


        }

}
6
  • Could you share how you do that in you code? Dec 19 '17 at 10:52
  • sure.... @Anime i updated my answer please check.
    – pooja
    Dec 19 '17 at 10:57
  • Please accept my answer to help others.@Anime
    – pooja
    Dec 19 '17 at 11:03
  • That does not seem magento preferred way. Dec 19 '17 at 11:17
  • ok i will try to get it in magento way. @Anime Thanks
    – pooja
    Dec 19 '17 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.