嗨我想按日期过滤magento order_invoice_item集合
作为参数我有一个timstamp-string“20130701T00:00:00”
我试图像那样过滤它
$invoiceitems = Mage::getModel('sales/order_invoice_item')->getCollection()
->addAttributeToFilter('sku', array('in' => $skuList))
->addAttributeToFilter('created_at', array('lt' => strtotime("20130701T00:00:00")));
但这不起作用,因为“created_at”在发票上。
如何加入发票以按日期过滤?
答案 0 :(得分:0)
我的解决方案是
$invoiceitems = Mage::getModel('sales/order_invoice_item')->getCollection()
->addAttributeToFilter('sku', array('in' => $skuList));
$invoiceitems->getSelect()->where("created_at >= CONVERT_TZ(FROM_UNIXTIME(".strtotime($from)."), @@session.time_zone,'UTC')");
$invoiceitems->getSelect()->where("created_at <= CONVERT_TZ(FROM_UNIXTIME(".strtotime($to)."), @@session.time_zone,'UTC')");
$invoiceitems->getSelect()->joinInner("sales_flat_invoice", "parent_id=sales_flat_invoice.entity_id", 'created_at');