3

I have problem with report when i was trying to create custom report(I am learning from magento default report module)

Error was

Fatal error: Uncaught Error: Call to a member function hasData() on null in
/var/www/html/balloonshopae/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php:102 Stack trace: #0
/var/www/html/balloonshopae/app/code/local/Company/Advancereport/Block/Adminhtml/Report/Sales/Sales/Grid.php(81): 
Mage_Adminhtml_Block_Report_Grid_Abstract->addColumn('total_qty_invoi...', Array) #1 
/var/www/html/balloonshopae/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(624): Company_Advancereport_Block_Adminhtml_Report_Sales_Sales_Grid->_prepareColumns() #2 
/var/www/html/balloonshopae/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(632): Mage_Adminhtml_Block_Widget_Grid->_prepareGrid() #3 
/var/www/html/balloonshopae/app/code/core/Mage/Core/Block/Abstract.php(922): Mage_Adminhtml_Block_Widget_Grid->_beforeToHtml() #4 
/var/www/html/balloonshopae/app/code/core/Mage/Core/Block/Abstract.php(641): Mage_Core_Block_Abstract->toHtml() #5 
/var/www/html/balloonshopae/app/code/core/Mage/Core/Block/Abstract.php(585): Mage_Core_Block_Abstract->_getCh in 
/var/www/html/balloonshopae/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php on line 102

Here is my controller action (controllers/Adminhtml/AdvancereportController.php)

public function salesAction()
{
 $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Sales'));
 $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_ORDER_FLAG_CODE, 'sales');
 $this->_initAction()
 ->_setActiveMenu('report/sales/sales')
 ->_addBreadcrumb(Mage::helper('adminhtml')->__('Sales Report'), Mage::helper('adminhtml')->__('Sales Report'));
 $gridBlock = $this->getLayout()->getBlock('report_sales_sales.grid');
 $filterFormBlock = $this->getLayout()->getBlock('grid.filter.form');
 $this->_initReportAction(array(
 $gridBlock,
 $filterFormBlock
 ));
 $this->renderLayout();
}

Here is my layout xml file (app/design/adminhtml/default/default/layout/advancereport.xml)

<advancereport_adminhtml_advancereport_sales>
 <update handle="report_sales"/>
 <reference name="content">
 <block type="advancereport/adminhtml_report_sales_sales" template="report/grid/container.phtml" name="sales.report.grid.container">
 <block type="adminhtml/store_switcher" template="report/store/switcher/enhanced.phtml" name="store.switcher">
 <action method="setStoreVarName"><var_name>store_ids</var_name></action>
 </block>
 <block type="sales/adminhtml_report_filter_form_order" name="grid.filter.form">
 <action method="addReportTypeOption" translate="value">
 <key>created_at_order</key>
 <value>Order Created Date</value>
 </action>
 <action method="addReportTypeOption" translate="value">
 <key>updated_at_order</key>
 <value>Order Updated Date</value>
 </action>
 <action method="setFieldOption" translate="value">
 <field>report_type</field>
 <option>note</option>
 <value>Order Updated Date report is real-time, does not need statistics refreshing.</value>
 </action>
 </block>
 </block>
 </reference>
</advancereport_adminhtml_advancereport_sales>

here is my block file (Block/Adminhtml/Report/Sales/Sales.php)

class Company_Advancereport_Block_Adminhtml_Report_Sales_Sales extends Mage_Adminhtml_Block_Widget_Grid_Container
{
 public function __construct()
 {
 $this->_blockGroup = 'advancereport';
 $this->_controller = 'adminhtml_report_sales_sales';
 $this->_headerText = Mage::helper('reports')->__('Total Ordered Report');
 parent::__construct();
 $this->setTemplate('report/grid/container.phtml');
 $this->_removeButton('add');
 $this->addButton('filter_form_submit', array(
 'label' => Mage::helper('reports')->__('Show Report'),
 'onclick' => 'filterFormSubmit()'
 ));
 }
 public function getFilterUrl()
 {
 $this->getRequest()->setParam('filter', null);
 return $this->getUrl('*/*/sales', array('_current' => true));
 }
}

Here is grid file (Advancereport/Block/Adminhtml/Report/Sales/Sales/Grid.php)

class Company_Advancereport_Block_Adminhtml_Report_Sales_Sales_Grid extends Mage_Adminhtml_Block_Report_Grid_Abstract
{
 protected $_columnGroupBy = 'period';
 public function __construct()
 {
 parent::__construct();
 $this->setCountTotals(true);
 }
 public function getResourceCollectionName()
 {
 return ($this->getFilterData()->getData('report_type') == 'updated_at_order')
 ? 'sales/report_order_updatedat_collection'
 : 'sales/report_order_collection';
 }
 protected function _prepareColumns()
 {
 $this->addColumn('period', array(
 'header' => Mage::helper('sales')->__('Period'),
 'index' => 'period',
 'width' => 100,
 'sortable' => false,
 'period_type' => $this->getPeriodType(),
 'renderer' => 'adminhtml/report_sales_grid_column_renderer_date',
 'totals_label' => Mage::helper('sales')->__('Total'),
 'html_decorators' => array('nobr'),
 ));
 $this->addColumn('orders_count', array(
 'header' => Mage::helper('sales')->__('Orders'),
 'index' => 'orders_count',
 'type' => 'number',
 'total' => 'sum',
 'sortable' => false
 ));
 $this->addColumn('total_qty_ordered', array(
 'header' => Mage::helper('sales')->__('Sales Items'),
 'index' => 'total_qty_ordered',
 'type' => 'number',
 'total' => 'sum',
 'sortable' => false
 ));
 $this->addColumn('total_qty_invoiced', array(
 'header' => Mage::helper('sales')->__('Items'),
 'index' => 'total_qty_invoiced',
 'type' => 'number',
 'total' => 'sum',
 'sortable' => false,
 'visibility_filter' => array('show_actual_columns')
 ));
 if ($this->getFilterData()->getStoreIds()) {
 $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds()));
 }
 $currencyCode = $this->getCurrentCurrencyCode();
 $rate = $this->getRate($currencyCode);
 $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,
 'rate' => $rate,
 ));
 $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'),
 'rate' => $rate,
 ));
 $this->addColumn('total_profit_amount', array(
 'header' => Mage::helper('sales')->__('Profit'),
 'type' => 'currency',
 'currency_code' => $currencyCode,
 'index' => 'total_profit_amount',
 'total' => 'sum',
 'sortable' => false,
 'visibility_filter' => array('show_actual_columns'),
 'rate' => $rate,
 ));
 $this->addColumn('total_invoiced_amount', array(
 'header' => Mage::helper('sales')->__('Invoiced'),
 'type' => 'currency',
 'currency_code' => $currencyCode,
 'index' => 'total_invoiced_amount',
 'total' => 'sum',
 'sortable' => false,
 'rate' => $rate,
 ));
 $this->addColumn('total_paid_amount', array(
 'header' => Mage::helper('sales')->__('Paid'),
 'type' => 'currency',
 'currency_code' => $currencyCode,
 'index' => 'total_paid_amount',
 'total' => 'sum',
 'sortable' => false,
 'visibility_filter' => array('show_actual_columns'),
 'rate' => $rate,
 ));
 $this->addColumn('total_refunded_amount', array(
 'header' => Mage::helper('sales')->__('Refunded'),
 'type' => 'currency',
 'currency_code' => $currencyCode,
 'index' => 'total_refunded_amount',
 'total' => 'sum',
 'sortable' => false,
 'rate' => $rate,
 ));
 $this->addColumn('total_tax_amount', array(
 'header' => Mage::helper('sales')->__('Sales Tax'),
 'type' => 'currency',
 'currency_code' => $currencyCode,
 'index' => 'total_tax_amount',
 'total' => 'sum',
 'sortable' => false,
 'rate' => $rate,
 ));
 $this->addColumn('total_tax_amount_actual', array(
 'header' => Mage::helper('sales')->__('Tax'),
 'type' => 'currency',
 'currency_code' => $currencyCode,
 'index' => 'total_tax_amount_actual',
 'total' => 'sum',
 'sortable' => false,
 'visibility_filter' => array('show_actual_columns'),
 'rate' => $rate,
 ));
 $this->addColumn('total_shipping_amount', array(
 'header' => Mage::helper('sales')->__('Sales Shipping'),
 'type' => 'currency',
 'currency_code' => $currencyCode,
 'index' => 'total_shipping_amount',
 'total' => 'sum',
 'sortable' => false,
 'rate' => $rate,
 ));
 $this->addColumn('total_shipping_amount_actual', array(
 'header' => Mage::helper('sales')->__('Shipping'),
 'type' => 'currency',
 'currency_code' => $currencyCode,
 'index' => 'total_shipping_amount_actual',
 'total' => 'sum',
 'sortable' => false,
 'visibility_filter' => array('show_actual_columns'),
 'rate' => $rate,
 ));
 $this->addColumn('total_discount_amount', array(
 'header' => Mage::helper('sales')->__('Sales Discount'),
 'type' => 'currency',
 'currency_code' => $currencyCode,
 'index' => 'total_discount_amount',
 'total' => 'sum',
 'sortable' => false,
 'rate' => $rate,
 ));
 $this->addColumn('total_discount_amount_actual', array(
 'header' => Mage::helper('sales')->__('Discount'),
 'type' => 'currency',
 'currency_code' => $currencyCode,
 'index' => 'total_discount_amount_actual',
 'total' => 'sum',
 'sortable' => false,
 'visibility_filter' => array('show_actual_columns'),
 'rate' => $rate,
 ));
 $this->addColumn('total_canceled_amount', array(
 'header' => Mage::helper('sales')->__('Canceled'),
 'type' => 'currency',
 'currency_code' => $currencyCode,
 'index' => 'total_canceled_amount',
 'total' => 'sum',
 'sortable' => false,
 'rate' => $rate,
 ));
 $this->addExportType('*/*/exportSalesCsv', Mage::helper('adminhtml')->__('CSV'));
 $this->addExportType('*/*/exportSalesExcel', Mage::helper('adminhtml')->__('Excel XML'));
 return parent::_prepareColumns();
 }
}
asked Jul 4, 2017 at 5:45
2
  • can you elaborate what problem are you facing? Commented Jul 4, 2017 at 5:46
  • update error log Commented Jul 4, 2017 at 5:48

1 Answer 1

0

Insufficient data:

Fatal error: Uncaught Error: Call to a member function hasData() on null in

this error is in complete please provide full error log as it is

you can find your full log at

sudo tail -f /var/log/php-fpm/www-error.log

your full error is looks like as below:

Uncaught Error: Class 'Classname' not found in /[file_path]/[filename.php]:[line number]

answered May 10, 2019 at 11:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.