Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Changes in creating invoices with Magento 1.0 / 1.1
 
bitfire.at
Jr. Member
 
Total Posts:  2
Joined:  2008-06-29
 

Hello,

I received this via Private Message:

If you used the following code in your payment modules to create invoices:

$convertor Mage::getModel(’sales/convert_order’);
    
$invoice $convertor->toInvoice($order);
    foreach (
$order->getAllItems() as $orderItem{
      
if (!$orderItem->getQtyToInvoice()) {
        
continue;
      
}
      $item 
$convertor->itemToInvoiceItem($orderItem);
      
$item->setQty($orderItem->getQtyToInvoice());
      
$invoice->addItem($item);
    
}

    $invoice
->collectTotals();

please make sure to use prepareInvoice() order model method instead. Example:

$invoice $order->prepareInvoice();

Now my questions:

1) Indeed my extension uses this code to create invoices. Does that mean that the whole code block can be replaced by the single line with prepareInvoice?

2) Is this compatible with Magento 1.0? Or shall I detect the Magento version in my extension and then execute the correct code according to the version?

 
Magento Community Magento Community
Magento Community
Magento Community
 
bitfire.at
Jr. Member
 
Total Posts:  2
Joined:  2008-06-29
 

Ok it seems that this function has been created in Magento 1.1 (according to Changelog), so I will check the Magento version. Maybe it would be not so nice if the extension requires Magento 1.1 suddenly. What do you think? How do you manage downward compatibility?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top