I am trying to insert multiple items on Db. It inserts successfully but when it comes to multiple items it duplicates it looks like am replacing on this array.

Here is the code:



        foreach($orderitems as $item){

            $aProduct = new OrderDetail;
            $aProduct->SkuId                        = $item->getSku();
            $aProduct->Quantity                     = number_format($item->getQtyOrdered(),0);
            $aProduct->Sellprice                    = number_format($item->getPrice(),2);
            $aProduct->LineNote                     = '';
            $aWebOrder->ProductDetailList[]         = $aProduct;

For those who will experience the same issue. In this case works like this:

Don't call getAllItems();


Replace it with:


This worked for me hoe it helps someone else. Thank you

Your Answer

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

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