Saturday 22 December 2012

Product Sold quantity display in your view page in magento.

This is a awesome code for showing the sold quantity of product in your magento store.

<?php
$sku = nl2br($_product->getSku());
$_productCollection = Mage::getResourceModel('reports/product_collection')
    ->addOrderedQty()
    ->addAttributeToFilter('sku', $sku)
    ->setOrder('ordered_qty', 'desc')
    ->getFirstItem();
$product = $_productCollection;

echo 'Already sold '.(int)$product->ordered_qty;

?>

No comments:

Post a Comment