1

I am creating order CSV file which is creating fine now I added item detail in order and show column in my CSV now I want if order has 2 items then 2 row creates in 1st row master column field like order id etc but and 1st item detail in 2nd row just 2nd item detail shows other columns should blank how I do that this is my code

foreach ($orders as $order) {
        foreach($order->getAllItems() as $orderItem){
        $fieldsss[] = array(

             $orderItem->getName(),



        );
   }
        $billingCountryCode = $order->getBillingAddress()->getCountryId();
        $billingCountry     = Mage::getModel('directory/country')->loadByCode($billingCountryCode);
        $billingCountryName = $billingCountry->getName();

        $shippingCountryCode = $order->getShippingAddress()->getCountryId();
        $shippingCountry     = Mage::getModel('directory/country')->loadByCode($shippingCountryCode);
        $shippingCountryName = $shippingCountry->getName();

        if ($order->hasInvoices()) {
            $oInvoiceCollection = $order->getInvoiceCollection();
            foreach ($oInvoiceCollection as $oInvoice) {
                $transaction_id = $oInvoice->getTransactionId();
            }
        } else {
            $transaction_id = '';
        }

        $payment = $order->getPayment();

        $fields[] = array(

            $order->getIncrementId(),

          $fieldsss,


        );


     }
    generateCsv($fields, $io);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.