2

I'm trying to make our packing slips and invoices more useful, especially when we have bundled products.

How can I show just the parent item and not the children in an invoice?

When I use $order->getAllItems() I get two lines in output:

parent-child sku

child sku

If I use $order->getAllVisibleItems() I only get the parent, which is what I want.

Parent sku

Now invoice->getAllItems with produces the two lines Parent-Child and Child But invoice->getAllVisibleItems with produces no lines

So it will show qty and amt on the invoice twice. not good for customers or packers.

<?php
require_once '../mage1/app/Mage.php';
require_once('Zend/Pdf.php');  
$app = Mage::app();
Mage::register('isSecureArea', true); 

$orderId = '500000555' ;  

$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);

foreach ($order->getAllVisibleItems() as $item){
    echo 'ITEM: ' . $item->getSku() . '<br />';
}
//vs invoice
echo 'Invoice Section <br />' ;

if ($order->hasInvoices()) {
    echo 'Order has invoices'  . '<br />';
foreach ($order->getInvoiceCollection() as $_eachInvoice) {

    foreach ($_eachInvoice->getAllVisibleItems as $invitem){
    //foreach ($_eachInvoice->getAllItems() as $invitem){
        //echo 'Object <br />';
        var_dump(get_object_vars($invitem));
        //print_r($invitem);  echo '<br /><br /><br /><br />';
        echo 'INVOICE ITEM: ' . $invitem->getSku() . '<br />';
        }
    }
} else { echo 'no invoices' ; };
?>
4

1 に答える 1

1

ジャストユース$invoice->getAllVisibleItems()とオーダーユース$order->getAllVisibleItems()

クラスに慣れるためget_class_methodに , get_class,を使ってみてください。get_class_vars

于 2012-09-27T12:11:27.550 に答える