我正在为现有的后端扩展添加额外的列。
我确定产品的销售情况以显示(大致)过去3个月的健康状况。
如果我实现此列,则生成该页面需要一分钟。
我添加到扩展程序的查询代码是:
$fromDate = date('Y-m-d H:i:s', strtotime('-90 days'));
$toDate = date('Y-m-d H:i:s', strtotime('-0 days'));
$collection->getSelect()->joinLeft(
array('order_items' => 'sales_flat_order_item'),
"`order_items`.`product_id` = `e`.`entity_id` AND
`order_items`.`created_at` BETWEEN '{$fromDate}' AND '{$toDate}'
AND `order_items`.`order_id` IN (SELECT entity_id FROM sales_flat_order
WHERE status = 'processing' OR status = 'complete' OR status = 'closed')
",
array('order_id', 'product_id')
);
$collection->getSelect()->columns('COUNT(order_items.order_id) AS stock_health');
$collection->getSelect()->group('e.entity_id');
我添加的列的代码是:
$stockManagerModel = Mage::getModel('stocklist/status');
$this->addColumn('stock_health', array(
'header' => 'Health', //Mage::helper('stocklist')->__('Health'),
'align' => 'right',
'filter' => false,
'width' => '60px',
'order_callback' => array($this, '_customSort'),
'renderer' => 'stocklist/adminhtml_widget_grid_column_renderer_health',
'index' => 'stock_health',
));
这次添加后导致此扩展程序如此缓慢的原因是什么?可以/应该做出哪些改变?有没有更好的方法来实现这个?
答案 0 :(得分:0)
有点怀疑,你在检查你的编译过程吗?是否禁用,或者在启用模块后运行编译过程?