答案 0 :(得分:0)
让我们一步一步检查:
模板(app / design / adminhtml / default / default / template / dashboard / index.phtml),第98行
<div class="dashboard-container">
<?php echo $this->getChildHtml('store_switcher') ?>
<table cellspacing="25" width="100%">
<tr>
<td>
<!-- Start including the sales blocks -->
<?php echo $this->getChildHtml('sales') ?>
<!-- End including -->
<div class="entry-edit">
<div class="entry-edit-head"><h4><?php echo $this->__('Last 5 Orders') ?></h4></div>
<fieldset class="np"><?php echo $this->getChildHtml('lastOrders'); ?></fieldset>
</div>
<div class="entry-edit">
<div class="entry-edit-head"><h4><?php echo $this->__('Last 5 Search Terms') ?></h4></div>
<fieldset class="np"><?php echo $this->getChildHtml('lastSearches'); ?></fieldset>
</div>
<div class="entry-edit">
<div class="entry-edit-head"><h4><?php echo $this->__('Top 5 Search Terms') ?></h4></div>
<fieldset class="np"><?php echo $this->getChildHtml('topSearches'); ?></fieldset>
</div>
</td>
您可以看到$this->getChildHtml('sales')
包含。那是从你的截图中负责这两个块终身销售和平均销售。
此模板来自阻止Mage_Adminhtml_Block_Dashboard
,您可以在其中找到_prepareLayout()
方法。
阻止类Mage_Adminhtml_Block_Dashboard (app / code / core / Mage / Adminhtml / Block / Dashboard.php)
protected function _prepareLayout()
{
...
$this->setChild('sales',
$this->getLayout()->createBlock('adminhtml/dashboard_sales')
);
...
}
如您所见,它使用块类Mage_Adminhtml_Block_Dashboard_Sales
设置块'sales'。
阻止类Mage_Adminhtml_Block_Dashboard_Sales (app / code / core / Mage / Adminhtml / Block / Dashboard / Sales.php)
现在它变得有趣了! :)
检查_prepareLayout
方法......
protected function _prepareLayout()
{
if (!Mage::helper('core')->isModuleEnabled('Mage_Reports')) {
return $this;
}
$isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group');
$collection = Mage::getResourceModel('reports/order_collection')
->calculateSales($isFilter);
if ($this->getRequest()->getParam('store')) {
$collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
} else if ($this->getRequest()->getParam('website')){
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
$collection->addFieldToFilter('store_id', array('in' => $storeIds));
} else if ($this->getRequest()->getParam('group')){
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
$collection->addFieldToFilter('store_id', array('in' => $storeIds));
}
$collection->load();
$sales = $collection->getFirstItem();
// HERE YOU GO!
$this->addTotal($this->__('Lifetime Sales'), $sales->getLifetime());
$this->addTotal($this->__('Average Orders'), $sales->getAverage());
}
你(希望)看到了什么:
Mage_Reports
启用_prepareLayout
方法
3。
醇>