I am loading products from a order with this
private function _addItens()
{
$this->_xml["itens"] = array();
$this->_xml["itens"]["item"] = array();
$cont=0;
foreach ($this->_orderModel->getItemsCollection() as $itemId => $item) {
$_product = Mage::getModel('catalog/product')->load( $item->product_id );
$this->_xml["itens"]["item"][$cont] =
array(
"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(),
//##HACK##
"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),
//##/HACK##
"origin" => $_product->getData( Lema21_Nfe_Model_TransformToXML::ATTR_COD_ORIGIN )
);
$cont++;
}
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.