3

I'm trying to get latest restocked product list from my Magento . For that i have been used this code, but it reflects nothing.

 $_productCollection = $_productCollection->joinField('is_in_stock',
                        'cataloginventory/stock_item',
                        'is_in_stock',
                        'product_id=entity_id',
                        '{{table}}.stock_id=1',
                        'left')
                    ->addAttributeToSort('updated_at','desc')
                    ->addAttributeToFilter('is_in_stock', array('gt' => 0));
2
  • What u mean by restocked?? I assume you want "the list of products you changed the stock details recently"
    – Sundar
    Commented Aug 19, 2015 at 4:19
  • as we know if i add to cart a product then its min from my Qty and when cancel this then my product will stock in my Qty . I want that list of product which Qty latest updated Commented Aug 19, 2015 at 4:23

2 Answers 2

1

As far as i researched, Magento is not tracking the qty changes. If you are good at handling magento code, You can trigger an event whenever item cancel happens.

In that event, you can make an observer function to makes the entry in your custom table.

That custom table will be growing over period of time. You can find the details of the products which has been cancelled/qty changed.

Hope this helps..! Let me know if you stuggle.

2
  • how to trigger an event for that Commented Aug 19, 2015 at 6:16
  • Mage::dispatchEvent('sales_order_item_cancel', array('item'=>$this)); This event will occur whenever user cancels the product, You can configure magento to run a function when the event occurs. Let that event store the product details to custom tables. . Following is a good link which can help u. ashsmith.io/2012/12/making-use-of-observers-in-magento
    – Sundar
    Commented Aug 19, 2015 at 9:01
1

Magento default don't have this functioning, wish it would have.

You have to create your own module for the same and consider below points while doing so.

  1. when order is cancled it should not be restocked.
  2. Also check for refund and other similar cases.

Its not an specific answer but you can start from here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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