Skip to content

Grid row total in case of Sales > Order Grid #13

@MagePsycho

Description

@MagePsycho

I tried to add the following approach to add total row in sales order grid.

#$this->_prepareTotals($block);
$this->_callProtectedMethod($block, '_prepareCollection');
$this->_prepareTotals($block);
/**
 * Prepare Order Totals row
 *
 */
protected function _prepareTotals($block)
{
    $block->_countTotals = true;
    $totals = new Varien_Object();
    $fields = array();
    $columns = array(
        'base_grand_total' => 0
    );
    foreach ($columns as $column => $value) {
        $fields[$column] = 0;
    }
    foreach ($block->getCollection() as $item) {
        //foreach ($fields as $field => $value) {
        $fromCur    = $item->getData('base_currency_code');
        $toCur      = 'USD';
        $baseAmount = $item->getData('base_grand_total');
        $amount     = Mage::helper('directory')->currencyConvert($baseAmount, $fromCur, $toCur);

        $fields['base_grand_total'] += $amount;
        //}
    }

    $totals->setData($fields);
    $block->setTotals($totals);

    return;
}

FYI, the same approach works fine if you extend the Mage_Sales_Block_Adminhtml_Sales_Order_Grid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions