Shopify, Shopify Apps, Magento, WordPress, Codeigniter, Joomla, Big Commerce | PHP
Showing posts with label Report. Show all posts
Showing posts with label Report. Show all posts
Monday, 26 November 2018
Monday, 11 April 2016
Today's/Month sales report on admin dashboard in magento
The sales report is one of the main progress indicators in e-commerce. We often create a sales report using the default Magento features – just go to Reports -> Sales -> Orders, and then, fill in the filter form on that page. This way allows us to get full information about sales on the web store.
Nevertheless, getting back to all these actions every time is not handy, especially if we do not need the full report. So, let’s find out how to display the reports in different parts in the admin panel.
First of all, we add a part of the code that will display our report on the dashboard in the admin panel – so, to do this place the following code snippet to
[Magento root]/app/design/adminhtml/default/default/template/dashboard/index.phtml:
<div class="entry-edit cmsdas-1 todaysale">In this code snippet we have a standard markup and use custom helper Mage::helper('NAMESPACE_MODULE/todaysale')->getTotals(). In this case, the helper returns an information about the report.
<div class="cms-entry-edit-head">
<div class="lifetime-sales"><?php echo "Today's sales" ?></div>
<div class="cms-va">
<span class="price"><?php echo Mage::helper('NAMESPACE_MODULE/todaysale')->getTotals();?></span>
<span style="font-size:14px; color:#686868;">
</span>
</div>
</div>
</div>
Pay attention to the code helper which generates information about the report. Here are several methods that build the report.
class NAMESPACE_MODULE_Helper_Todaysale extends Mage_Core_Helper_Abstract {
public function getTotals() {
$isFilter= '';
$todaysales = Mage::getResourceModel('reports/order_collection')
->calculateSales($isFilter);
$todayStartOfDayDate = Mage::app()->getLocale()->date()
->setTime('00:00:00')
->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
//$todayStartOfDayDate ='2016-04-7 00:00:00';
$todayEndOfDayDate = Mage::app()->getLocale()->date()
->setTime('23:59:59')
->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$todaysales->addAttributeToFilter('created_at', array(
'from' => $todayStartOfDayDate,
'to' => $todayEndOfDayDate,
));
$todaysales->load();
$todaysale = $todaysales->getFirstItem();
//$this->addTotal($this->__("Today's Sales"), $todaysale->getLifetime());
return (string)Mage::helper('core')->currency($todaysale->getLifetime(), true, false);
}
}
Subscribe to:
Posts (Atom)