To get Recently Sold Products

Posted: November 7, 2012 in Magento, Version 1.3.*, Version 1.4.*, Version 1.6.*

Hello All,

I like to share small code snippet to last 12 product details which are recently sold from the store.

public function getRecentlySoldItems()
$storeID = Mage::app()->getStore()->getId();
$itemsCollection = Mage::getResourceModel('sales/order_item_collection')
->join('order', 'order_id=entity_id')
->addFieldToFilter('main_table.store_id', array('eq'=>$storeID))
$products = array();
foreach ($itemsCollection as $item) {
$product = Mage::getModel('catalog/product')

$products[] = $product;

return $products;


Above function will return array of products.

I hope you will find the above code useful.

Bijal Bhavsar 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s