0

hi i want to filter an magento order_invoice_item collection by date

as parameter i have a timstamp-string "20130701T00:00:00"

i trid to filter it like that

$invoiceitems = Mage::getModel('sales/order_invoice_item')->getCollection()
->addAttributeToFilter('sku', array('in' => $skuList))
->addAttributeToFilter('created_at', array('lt' => strtotime("20130701T00:00:00")));

but this won't work because the "created_at" is on the invoice.

how can i join the invoice to filter it by date?

4

1 回答 1

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');
于 2013-08-21T14:31:43.673 回答