1
votes

A client noticed that the Admin Dashboard calculations in her system aren’t matching up with the Order report, in that what’s being called ‘Revenue’ is actually displaying profit as demonstrated in the attached shots.

order report

What I want to do is modify the Dashboard page to add a 5th element which would be the actual Revenue and not Profit.

I’ve gotten as far adding the element to the page.

admin dashboard

To do this I copied Totals.php from /app/code/core/Mage/Adminhtml/Block/Dashboard/ to /app/code/local/Mage/Adminhtml/Block/Dashboard/. This is the code that I modified:

    $totals = $collection->getFirstItem();
    $this->addTotal($this->__('Revenue'), $totals->getProfit());
    $this->addTotal($this->__('Profit'), $totals->getRevenue());
    $this->addTotal($this->__('Tax'), $totals->getTax());
    $this->addTotal($this->__('Shipping'), $totals->getShipping());
    $this->addTotal($this->__('Quantity'), $totals->getQuantity()*1, true);

I just can’t seem to find the actual variable that I need to call. Does anyone have any idea how I can locate it or what it might be? I've tried Sales, SalesTotal, Invoiced and they all return zero.

It’s the value that’s being displayed as Sales Total in the 1st image.

Thanks.

EDIT

The variable that I'm looking for isn't loading in this file. I've hunted down Grid.php in /app/code/core/Mage/Adminhtml/Block/Report/Sales/Sales/ which is what's drawing the table in the 1st image.

I've tried inserting

Mage::log($totals->debug());

in various places but it causes an error in each instance.

Here's a snippet of code from Grid.php, either of these values would work for me..

$this->addColumn('total_income_amount', array(
        'header'        => Mage::helper('sales')->__('Sales Total'),
        'type'          => 'currency',
        'currency_code' => $currencyCode,
        'index'         => 'total_income_amount',
        'total'         => 'sum',
        'sortable'      => false
    ));

    $this->addColumn('total_revenue_amount', array(
        'header'        => Mage::helper('sales')->__('Revenue'),
        'type'          => 'currency',
        'currency_code' => $currencyCode,
        'index'         => 'total_revenue_amount',
        'total'         => 'sum',
        'sortable'      => false,
        'visibility_filter' => array('show_actual_columns')
    ));
1
Bumping for Monday morning...Anyone? :)nero
Comments don't bump a question any higher. Also I added a magento tag since more people are likely to see that.clockworkgeek

1 Answers

0
votes

Turn on logging in System > Configuration > Developer and then next to your overridden code put:

Mage::log($totals->debug());

Watch the "var/log/system.log" file as you refresh the page and it will dump $totals for you. Find the index of the value you want and convert it to camel case, for example if you see sales_total then you can use $totals->getSalesTotal() (which you have already tried, this is only an example).

Remember to turn off logging when the site goes live.