2016-05-13 8 views

答えて

0

レッツ・チェックステップバイステップ:

テンプレート(アプリ/設計/ adminhtml /デフォルト/デフォルト/テンプレート/ダッシュボード/ 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')が表示されます。その2つのブロックの責任を負います生涯販売平均売上スクリーンショットから。

このテンプレートは、ブロックMage_Adminhtml_Block_Dashboardから来ており、_prepareLayout()という方法があります。

ブロッククラスMage_Adminhtml_Block_Dashboard(アプリ/コード/コア/メイジ/ Adminhtml /ブロック/ Dashboard.php)

protected function _prepareLayout() 
{ 
    ... 
     $this->setChild('sales', 
      $this->getLayout()->createBlock('adminhtml/dashboard_sales') 
     ); 
    ... 
} 

あなたが見ることができるように、それはブロッククラスMage_Adminhtml_Block_Dashboard_Salesとブロックの販売」を設定し、 。

ブロッククラスMage_Adminhtml_Block_Dashboard_Sales(アプリ/コード/コア/メイジ/ Adminhtml /ブロック/ダッシュボード/ Sales.php)

今それが面白いです! :)

あなたは(たぶん)を参照

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()); 
} 

何... _prepareLayout方法を確認してください:

  1. Mage_Reports
  2. ブロックである有効になっている場合、これら二つのブロックのみが示されています基本的にはここでハードコードされています
  3. 間に何かを書きたい場合は_prepareLayoutメソッドを自分で作成する
関連する問題