2

When placing an order with configurable product, Some products ordered twice. For example,

Configurable product sku is fst (full sleeve top)

And its associated product skus are fst_s,fst_m,fst_l (small,medium,large)

I have ordered fst_s with quantity 2 and fst_m with quantity 1 products. After placed an order, Order total amount being wrong. When i inspect an order details, I got following information

In admin, sales order view page, I have only 3 quantity.But, if i get order details via code, I got quantity 5.

Type: configurable
Item Name: Full Sleeve Top
Item Id: 3483
Item Sku: fst_s
Item Qty: 2.0000
Item Price: 20.0000

Type: simple
Item Name: Full Sleeve Top
Item Id: 3484
Item Sku: fst_s
Item Qty: 1.0000
Item Price: 20.0000

Type: configurable
Item Name: Full Sleeve Top
Item Id: 3483
Item Sku: fst_m
Item Qty: 1.0000
Item Price: 20.0000

Type: simple
Item Name: Full Sleeve Top
Item Id: 3485
Item Sku: fst_m
Item Qty: 1.0000
Item Price: 20.0000

Simple product added again with 1 quantity. I don't have an idea, why its happening like this. In admin area, Its showing fine Except order total ($100). In Order invoice, Its showing correct amount- $60(exclude repeated simple product amount). I have placed my code what i have checked below

$order = Mage::getModel('sales/order')->loadByIncrementId(100000003);
$orderItems = $order->getItemsCollection()
        ->addAttributeToSelect('*')      
        ->load();
        foreach($orderItems as $sItem) {
            if($sItem->getPrice()==0){continue;}
            echo "Type: ".$sItem->getProductType()."<br/>";
            echo "Item Name: ".$sItem->getName()."<br/>";
            echo "Item Id: ".$sItem->getProductId()."<br/>";
             echo "Item Sku: ".$sItem->getSku()."<br/>";
             echo "Item Qty: ".$sItem->getQtyOrdered()."<br/>";
             echo "Item Price: ".$sItem->getPrice()."<br/>";
        }
//print_r($order->getData());

Eagarly awaiting for your response!

0

Everytime you add a configurable product to your quote, Magento will add the corresponding simple product silently. This is required to be able to reduce the stock amount afterwards and may contain some other additional information.

So in most cases, you might want to skip the simple product, if there is a parent_item_id. So in your code, add

            if ($sItem->getParentItemId()) { continue; }

at the beginning of your foreach loop.

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.