Skip to main content
replaced http://magento.stackexchange.com/ with https://magento.stackexchange.com/
Source Link
added 934 characters in body
Source Link
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239

Edit:

You custom renderer class .Please check http://inchoo.net/magento/how-to-add-custom-renderer-for-a-custom-column-in-magento-grid/ first.

From:

 $this->addColumn('total_price', array(
                'header' => Mage::helper('sales')->__('Total),
                'index' => 'total_price,
                'type'  => 'currency',
                'currency' => 'base_currency_code',
            ));

change:

$this->addColumn('total_price',
array(
'header'=> Mage::helper('total_price')->__('Order total price'),
'index' => 'total_price',
'renderer'  => 'Mage_Adminhtml_Block_Catalog_Product_Renderer_Red',// THIS IS WHAT THIS POST IS ALL ABOUT
));
 
}

Add

public function render(Varien_Object $row)
{
$value =  $row->getData($this->getColumn()->getIndex());
return '$'.$value.'</span>';
 
}

Edit:

You custom renderer class .Please check http://inchoo.net/magento/how-to-add-custom-renderer-for-a-custom-column-in-magento-grid/ first.

From:

 $this->addColumn('total_price', array(
                'header' => Mage::helper('sales')->__('Total),
                'index' => 'total_price,
                'type'  => 'currency',
                'currency' => 'base_currency_code',
            ));

change:

$this->addColumn('total_price',
array(
'header'=> Mage::helper('total_price')->__('Order total price'),
'index' => 'total_price',
'renderer'  => 'Mage_Adminhtml_Block_Catalog_Product_Renderer_Red',// THIS IS WHAT THIS POST IS ALL ABOUT
));
 
}

Add

public function render(Varien_Object $row)
{
$value =  $row->getData($this->getColumn()->getIndex());
return '$'.$value.'</span>';
 
}
added 489 characters in body
Source Link
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239

First,please follow @Amast post

Magento Customer Grid - Last Order Date

You can get Customer total order from this link...

But for getting total price .use below code

     $total_pricesql ='SELECT sum(o.base_grand_total)'
            . ' FROM ' . Mage::getSingleton('core/resource')->getTableName('sales/order') . ' AS o'
            . ' WHERE o.customer_id = e.entity_id ';
        $expr = new Zend_Db_Expr('(' . $total_pricesql . ')'); 
    
        $collection->getSelect()->from(null, array('total_price'=>$expr));
    $Totalsql ='SELECT COUNT(*)'
        . ' FROM ' . Mage::getSingleton('core/resource')->getTableName('sales/order') . ' AS o'
        . ' WHERE o.customer_id = e.entity_id ';
    $Totalsqlexpr = new Zend_Db_Expr('(' . $Totalsql . ')'); 

    $collection->getSelect()->from(null, array('orders_count'=>$Totalsqlexpr));




$this->addColumn('orders_count', array(
        'header'    => Mage::helper('customer')->__('Orders Count'),
        'index'     => 'orders_count',
    ));
    
            $this->addColumn('total_price', array(
                'header' => Mage::helper('sales')->__('Total),
                'index' => 'total_price,
                'type'  => 'currency',
                'currency' => 'base_currency_code',
            ));

First,please follow @Amast post

Magento Customer Grid - Last Order Date

You can get Customer total order from this link...

But for getting total price .use below code

 $total_pricesql ='SELECT sum(o.base_grand_total)'
        . ' FROM ' . Mage::getSingleton('core/resource')->getTableName('sales/order') . ' AS o'
        . ' WHERE o.customer_id = e.entity_id ';
    $expr = new Zend_Db_Expr('(' . $total_pricesql . ')'); 

    $collection->getSelect()->from(null, array('total_price'=>$expr));


        $this->addColumn('total_price', array(
            'header' => Mage::helper('sales')->__('Total),
            'index' => 'total_price,
            'type'  => 'currency',
            'currency' => 'base_currency_code',
        ));

First,please follow @Amast post

Magento Customer Grid - Last Order Date

You can get Customer total order from this link...

But for getting total price .use below code

     $total_pricesql ='SELECT sum(o.base_grand_total)'
            . ' FROM ' . Mage::getSingleton('core/resource')->getTableName('sales/order') . ' AS o'
            . ' WHERE o.customer_id = e.entity_id ';
        $expr = new Zend_Db_Expr('(' . $total_pricesql . ')'); 
    
        $collection->getSelect()->from(null, array('total_price'=>$expr));
    $Totalsql ='SELECT COUNT(*)'
        . ' FROM ' . Mage::getSingleton('core/resource')->getTableName('sales/order') . ' AS o'
        . ' WHERE o.customer_id = e.entity_id ';
    $Totalsqlexpr = new Zend_Db_Expr('(' . $Totalsql . ')'); 

    $collection->getSelect()->from(null, array('orders_count'=>$Totalsqlexpr));




$this->addColumn('orders_count', array(
        'header'    => Mage::helper('customer')->__('Orders Count'),
        'index'     => 'orders_count',
    ));
    
            $this->addColumn('total_price', array(
                'header' => Mage::helper('sales')->__('Total),
                'index' => 'total_price,
                'type'  => 'currency',
                'currency' => 'base_currency_code',
            ));
added 408 characters in body
Source Link
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239
Loading
Post Undeleted by Amit Bera
Post Deleted by Amit Bera
Source Link
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239
Loading