我正在关注此帖子Change the Dashboard Graph in version 1.7/1.12 of Magento,以允许销售“处理”订单显示在信息中心图表上。我的文件位于正确的目录下方,并且在config> advanced中显示为活动状态。我还重新编制了索引,刷新了缓存,并刷新了生命周期统计信息。我发现日志中没有错误。你能看出什么问题吗?我有firegento并启用了日志记录,但这也无法正常工作。
编辑:仪表板上的收入总额似乎是正确的,但它没有反映在时间线图上。例如,上午10点可能有30美元的净30项订单,但它没有显示在时间图上。赏金给谁可以修改下面的脚本以反映我的时间表!
CaitlinHavener /仪表板的/ etc / config.xml中:
<?xml version="1.0"?>
<config>
<modules>
<CaitlinHavener_Dashboard>
<version>1.0</version>
</CaitlinHavener_Dashboard>
</modules>
<global>
<models>
<CaitlinHavener_Dashboard>
<class>CaitlinHavener_Dashboard_Model</class>
</CaitlinHavener_Dashboard>
<reports_resource>
<rewrite>
<order_collection>CaitlinHavener_Dashboard_Model_Reports_Resource_Order_Collection</order_collection>
</rewrite>
</reports_resource>
</models>
</global>
</config>
CaitlinHavener /仪表板/型号/报告/资源/订购/ Collection.php
<?php
/**
* Show all orders, not only the invoiced one
*/
class CaitlinHavener_Dashboard_Model_Reports_Resource_Order_Collection extends Mage_Reports_Model_Resource_Order_Collection
{
protected function _prepareSummaryLive($range, $customStart, $customEnd, $isFilter = 0)
{
$this->setMainTable('sales/order');
$adapter = $this->getConnection();
/**
* Reset all columns, because result will group only by 'created_at' field
*/
$this->getSelect()->reset(Zend_Db_Select::COLUMNS);
/* $expression = sprintf('%s - %s - %s - (%s - %s - %s)',
$adapter->getIfNullSql('main_table.base_total_invoiced', 0),
$adapter->getIfNullSql('main_table.base_tax_invoiced', 0),
$adapter->getIfNullSql('main_table.base_shipping_invoiced', 0),
$adapter->getIfNullSql('main_table.base_total_refunded', 0),
$adapter->getIfNullSql('main_table.base_tax_refunded', 0),
$adapter->getIfNullSql('main_table.base_shipping_refunded', 0)
); */
$expression = sprintf('%s - %s - %s - (%s - %s - %s)',
$adapter->getIfNullSql('main_table.base_total_invoiced', 'main_table.base_grand_total'),
$adapter->getIfNullSql('main_table.base_tax_invoiced', 'main_table.base_tax_amount'),
$adapter->getIfNullSql('main_table.base_shipping_invoiced', 'main_table.base_shipping_amount'),
$adapter->getIfNullSql('main_table.base_total_refunded', 0),
$adapter->getIfNullSql('main_table.base_tax_refunded', 0),
$adapter->getIfNullSql('main_table.base_shipping_refunded', 0)
);
if ($isFilter == 0) {
$this->getSelect()->columns(array(
'revenue' => new Zend_Db_Expr(
sprintf('SUM((%s) * %s)', $expression,
$adapter->getIfNullSql('main_table.base_to_global_rate', 0)
)
)
));
} else {
$this->getSelect()->columns(array(
'revenue' => new Zend_Db_Expr(sprintf('SUM(%s)', $expression))
));
}
$dateRange = $this->getDateRange($range, $customStart, $customEnd);
$tzRangeOffsetExpression = $this->_getTZRangeOffsetExpression(
$range, 'created_at', $dateRange['from'], $dateRange['to']
);
$this->getSelect()
->columns(array(
'quantity' => 'COUNT(main_table.entity_id)',
'range' => $tzRangeOffsetExpression,
))
//BOF modification
->where('main_table.state NOT IN (?)', array(
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
// Mage_Sales_Model_Order::STATE_NEW
)
)
//EOF modification
->order('range', Zend_Db_Select::SQL_ASC)
->group($tzRangeOffsetExpression);
$this->addFieldToFilter('created_at', $dateRange);
return $this;
}
protected function _calculateTotalsLive($isFilter = 0)
{
$this->setMainTable('sales/order');
$this->removeAllFieldsFromSelect();
$adapter = $this->getConnection();
// $baseTotalInvoiced = $adapter->getIfNullSql('main_table.base_grand_total', 0);
// $baseTotalRefunded = $adapter->getIfNullSql('main_table.base_discount_refunded', 0);
// $baseTaxInvoiced = $adapter->getIfNullSql('main_table.base_tax_amount', 0);
// $baseTaxRefunded = $adapter->getIfNullSql('main_table.base_tax_refunded', 0);
// $baseShippingInvoiced = $adapter->getIfNullSql('main_table.base_shipping_amount', 0);
// $baseShippingRefunded = $adapter->getIfNullSql('main_table.base_shipping_refunded', 0);
// $baseShippingRefunded = $adapter->getIfNullSql('main_table.base_shipping_refunded', 0);
$baseTotalInvoiced = $adapter->getIfNullSql('main_table.base_total_invoiced', 'main_table.base_grand_total'); // This will check if there is no invoice it will calculate based on the grand totals ( so when you generate and invoice u will have no issues with the numbers also )
$baseTotalRefunded = $adapter->getIfNullSql('main_table.base_total_refunded', 0);
$baseTaxInvoiced = $adapter->getIfNullSql('main_table.base_tax_invoiced', 'main_table.base_tax_amount'); // Same here for taxes
$baseTaxRefunded = $adapter->getIfNullSql('main_table.base_tax_refunded', 0);
$baseShippingInvoiced = $adapter->getIfNullSql('main_table.base_shipping_invoiced', 'main_table.base_shipping_amount'); // Same here for shipping
$baseShippingRefunded = $adapter->getIfNullSql('main_table.base_shipping_refunded', 0);
$revenueExp = sprintf('%s - %s - %s - (%s - %s - %s)',
$baseTotalInvoiced,
$baseTaxInvoiced,
$baseShippingInvoiced,
$baseTotalRefunded,
$baseTaxRefunded,
$baseShippingRefunded
);
$taxExp = sprintf('%s - %s', $baseTaxInvoiced, $baseTaxRefunded);
$shippingExp = sprintf('%s - %s', $baseShippingInvoiced, $baseShippingRefunded);
if ($isFilter == 0) {
$rateExp = $adapter->getIfNullSql('main_table.base_to_global_rate', 0);
$this->getSelect()->columns(
array(
'revenue' => new Zend_Db_Expr(sprintf('SUM((%s) * %s)', $revenueExp, $rateExp)),
'tax' => new Zend_Db_Expr(sprintf('SUM((%s) * %s)', $taxExp, $rateExp)),
'shipping' => new Zend_Db_Expr(sprintf('SUM((%s) * %s)', $shippingExp, $rateExp))
)
);
} else {
$this->getSelect()->columns(
array(
'revenue' => new Zend_Db_Expr(sprintf('SUM(%s)', $revenueExp)),
'tax' => new Zend_Db_Expr(sprintf('SUM(%s)', $taxExp)),
'shipping' => new Zend_Db_Expr(sprintf('SUM(%s)', $shippingExp))
)
);
}
$this->getSelect()->columns(array(
'quantity' => 'COUNT(main_table.entity_id)'
))
->where('main_table.state NOT IN (?)', array(
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
//Mage_Sales_Model_Order::STATE_NEW
)
);
return $this;
}
}
?>
答案 0 :(得分:4)
您必须了解Magento中的订单流程,以便您可以完全了解图表的填充方式
现在,如果您查看前面的步骤,如果订单位于新并且取消 STATE (非状态),您将看到不应计算收入
应该在订单开具发票时进行计算(这样您就可以获得收入和运费以及退款)
所以要计算收入中的新状态订单和图表覆盖方法
app/code/core/Mage/Reports/Model/Resource/Order/Collection.php /** * Calculate totals live report * * @param int $isFilter * @return Mage_Reports_Model_Resource_Order_Collection */ protected function _calculateTotalsLive($isFilter = 0){}
// Line 430
->where('main_table.state NOT IN (?)', array(
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
Mage_Sales_Model_Order::STATE_NEW // Comment this line
)
);
所以现在如果你对这一行发表评论,那么订单将计入( ORDERS图表图)
但总计仍未计算(因为没有发票/发货/退款)
所以你需要改变计算过程,使用发票金额才能在发票之前使用TOTALS只需很小的改动即可实现你想要的而不会出现错误代码如下
更改线条(390及以下内容如下):
$baseTotalInvoiced = $adapter->getIfNullSql('main_table.base_total_invoiced', 'main_table.base_grand_total'); // This will check if there is no invoice it will calculate based on the grand totals ( so when you generate and invoice u will have no issues with the numbers also )
$baseTotalRefunded = $adapter->getIfNullSql('main_table.base_total_refunded', 0);
$baseTaxInvoiced = $adapter->getIfNullSql('main_table.base_tax_invoiced', 'main_table.base_tax_amount'); // Same here for taxes
$baseTaxRefunded = $adapter->getIfNullSql('main_table.base_tax_refunded', 0);
$baseShippingInvoiced = $adapter->getIfNullSql('main_table.base_shipping_invoiced', 'main_table.base_shipping_amount'); // Same here for shipping
$baseShippingRefunded = $adapter->getIfNullSql('main_table.base_shipping_refunded', 0);
所以在简单的回答中解决方案没有改变计算方式,但解决方案改变了计算的默认值
按照这些更改,你会得到你想要的东西:)