3

I have tried getTotalQtyOrdered() but still not success, Any idea guys?

    $dirPath = Mage::getBaseDir('var') . DS . 'export';

if (!is_dir($dirPath)) {
mkdir($dirPath, 0777, true);
}

foreach ($order->getAllVisibleItems() as $item){

  $data[] = array(

        'ID'    => $item->getSku(),
        'QTY'   => $item->getQty(),
        'PRICE' => $item->getPrice()

        );

     }


    $xml = new SimpleXMLElement('<root/>');
    foreach ($data as $item) {
    $xmlItem = $xml->addChild('item');
    foreach ($item as $key => $value) {
            $xmlItem->addChild($key, $value);
        }
    }

    file_put_contents($dirPath. DS .$order->getIncrementId().'.xml', $xml->asXML());

1 Answer 1

5

See sales_flat_order_item table in the database to see what values are stored. Alternatively you can also get a view of the data fields with var_dump($item->debug());.

You are likely looking for

$item->getQtyOrdered()

or potentially

$item->getQtyInvoiced()
2
  • This is the result i get: <?xml version="1.0"?> <root> <item> <ID>10000002</ID> <QTY/> <PRICE>171.34</PRICE> </item> <item> <ID>10000005</ID> <QTY/> <PRICE>555</PRICE> </item> </root> In both cases.
    – DanielDake
    Commented Oct 22, 2013 at 17:37
  • 1
    It was $item->getQtyOrdered() thank you very much.
    – DanielDake
    Commented Oct 22, 2013 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.