我使用此代码以PDF格式获取订单的发票日期,并将此代码放入此文件" app / code / core / Mage / Sales / Model / Order / Pdf / Abstract.php& #34; 但它显示当前日期而不是发票创建日期。
$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceIncrementId);
$createdDate = strtotime( $invoice->getCreatedAt() );
$page->drawText(
Mage::helper('sales')->__('Invoice Creation Date: ') . Mage::helper('core')->formatDate(
$createdDate, 'medium', false
),
35,
($top -= 15),
'UTF-8'
);
答案 0 :(得分:1)
不要使用strtotime()
,magento本身会处理它。尝试使用此
$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceIncrementId);
$createdDate = $invoice->getCreatedAt();
$page->drawText(
Mage::helper('sales')->__('Invoice Creation Date: ') . Mage::helper('core')->formatDate(
$createdDate, 'medium', false
),
35,
($top -= 15),
'UTF-8'
);
答案 1 :(得分:1)
我用这段代码解决了它。
$order_increment_idd = $order->getRealOrderId();
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$query = "Select * from `sales_flat_invoice_grid` WHERE `order_increment_id` ='$order_increment_idd' LIMIT 1";
$rows = $connection->fetchAll($query);
foreach ($rows as $values) {
$createdDate = $values['created_at'];
$page->drawText(
Mage::helper('sales')->__('Date: ') . Mage::helper('core')->formatDate(
$createdDate, 'medium', false
),
35,
($top -= 15),
'UTF-8'
);
}