To display how many time product is sold you have to create a rendered in product grid.
Add this code in your admin grid.
class Techtown_Adminx_Block_Adminhtml_Adminx_Renderer_Salesreturn extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function render(Varien_Object $row)
{
$productID = $row->getId();
$product = Mage::getModel('catalog/product')->load($productID);
$sku = nl2br($product->getSku());
//$to = $_product->getResource()->formatDate(time());
//$from = $_product->getResource()->formatDate(time() - 60 * 60 * 24 * 1);
$product = Mage::getResourceModel('reports/product_collection')
->addOrderedQty(true)
->addAttributeToFilter('sku', $sku)
->setOrder('ordered_qty', 'desc')
->getFirstItem();
echo '<a href="#" class="adminx-sales-return-grid">'.(int)$product->ordered_qty.'</a>';
}
}
Add this code in your admin grid.
class Techtown_Adminx_Block_Adminhtml_Adminx_Renderer_Salesreturn extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function render(Varien_Object $row)
{
$productID = $row->getId();
$product = Mage::getModel('catalog/product')->load($productID);
$sku = nl2br($product->getSku());
//$to = $_product->getResource()->formatDate(time());
//$from = $_product->getResource()->formatDate(time() - 60 * 60 * 24 * 1);
$product = Mage::getResourceModel('reports/product_collection')
->addOrderedQty(true)
->addAttributeToFilter('sku', $sku)
->setOrder('ordered_qty', 'desc')
->getFirstItem();
echo '<a href="#" class="adminx-sales-return-grid">'.(int)$product->ordered_qty.'</a>';
}
}
No comments:
Post a Comment