個々の製品の請求書を作成するために Magento 管理者にリンクを作成しましたが、関数を呼び出すと、$order->prepareInvoice($qtys)
1 つのアイテムしか渡していなくても、すべての製品が請求書に追加されます。
以下のコードを使用しています。
$order = Mage::getModel('sales/order')->load($this->getRequest()->getParam('order_id'));
$count = $order->getTotalItemCount();
$qtys = Array
(
[370] => 1
);
$invoice = $order->prepareInvoice($qtys);
if (!$invoice->getTotalQty()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
}
$amount = $invoice->getGrandTotal();
$invoice->register()->pay();
$invoice->getOrder()->setIsInProcess(true);
$history = $invoice->getOrder()->addStatusHistoryComment('Partial amount of $'. $amount .' captured automatically.', false);
$history->setIsCustomerNotified(true);
$order->save();
Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($invoice->getOrder())
->save();
$invoice->save();
なにか提案を ?