I am loading products from a order with this

private function _addItens()

    $this->_xml["itens"] = array();
    $this->_xml["itens"]["item"] = array();

    foreach ($this->_orderModel->getItemsCollection() as $itemId => $item) {

        $_product = Mage::getModel('catalog/product')->load( $item->product_id );

        $this->_xml["itens"]["item"][$cont] = 
                "cod" => $item->getSku(),
                "description" => $_product->getData(Lema21_Nfe_Model_TransformToXML::ATTR_OPERATION_NAME),
                "un"    => $_product->getData(Lema21_Nfe_Model_TransformToXML::ATTR_OPERATION_UNIT),
                "qty"  => $item->getData("qty_ordered"),
                "un_price" => $item->getPrice(),
                "type" => self::PRODUCT_OR_SERVICE,
                "weight" => $item->getWeight(),
                "final_weight"  => $item->getWeight(),

                "manufacturer" => $_product->getAttributeText(Lema21_Nfe_Model_TransformToXML::ATTR_NAME_MANUFACTURER),
                "class_fiscal" => $_product->getData(Lema21_Nfe_Model_TransformToXML::ATTR_COD_NCM),
                "_icms" => $_product->getData(Lema21_Nfe_Model_TransformToXML::ATTR_COD_ICMS),

                "origin"    => $_product->getData( Lema21_Nfe_Model_TransformToXML::ATTR_COD_ORIGIN )


    return $this;

and that's working for all kinds of products, but when a configurable product arrives, the code return 2 results: the configurable product and the simple product. Since the program work with taxes and stuff, I can't hold these 2 results, I need just one. I need only the simple product, the one that my client chose.

1 Answer 1


You can use:

$item->getParentId() and $item->getProductType() 

to determine if must be included or not in the array.

If you want to export just simple products data exclude those who are 'configurables' if you want to export the configurable but not their childs just exclude those who are 'simples' and has parent.

Your Answer

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

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