2

Magento でプログラムで注文を追加するスクリプトを作成しています。コメント履歴のエントリの日付 (見積もり、請求書、発送など) を変更するのに助けが必要です。注文自体の日付 (setCreatedAt) を操作することはできますが、注文の作成に関するコメントの一部は正しいものです (例: 「2008 年 9 月 29 日 8:59:25 AM|保留中の顧客通知は該当しません」)。 addStatusHistoryComment を使用すると、コメントの日付を変更できません...

これが私のコードのスニペットです:

try {
if(!$order->canInvoice()) {
  Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
}
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
if (!$invoice->getTotalQty()) {
  Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without   products.'));
}

$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
$invoice->setCreatedAt('2008-09-23 13:05:20');
$invoice->register();
$invoice->getOrder()->setCustomerNoteNotify(true);
$invoice->getOrder()->setIsInProcess(true);
$transactionSave = Mage::getModel('core/resource_transaction')
  ->addObject($invoice)
-  >addObject($invoice->getOrder());

$transactionSave->save();
//END Handle Invoice

//START Handle Shipment
$shipment = $order->prepareShipment();
$shipment->setCreatedAt('2008-09-23 14:20:10');
$shipment->register();
$order->setIsInProcess(true);
$order->addStatusHistoryComment('Shipping message goes here...', true);
$shipment->setEmailSent(true);
$transactionSave = Mage::getModel('core/resource_transaction')
  ->addObject($shipment)
  ->addObject($shipment->getOrder())
  ->save();
$track = Mage::getModel('sales/order_shipment_track')
  ->setShipment($shipment)
  ->setData('title', 'Some tracking no.')
  ->setData('number', '111222333444')
  ->setData('carrier_code', 'fedex') //custom, fedex, ups, usps, dhl
  ->setData('order_id', $shipment->getData('order_id'))
  ->save();
//END Handle Shipment
}
catch (Mage_Core_Exception $ex) {
  echo "Problem creating order invoice and/or shipment: ".$ex."\n";
}

コメント履歴のスクリーンショット: ! http://www.etechparts.us/media/downloadable/files/links/CommentsHistory_Magento.png

前もって感謝します。

4

2 に答える 2