protected function completeCSVertical()
 {
     $order_line = field_get_items('commerce_order', $this->datasources["order"], 'commerce_line_items');
     $line_item_ids[] = $order_line[0]['line_item_id'];
     $line_item = commerce_line_item_load_multiple($line_item_ids);
     $product_ids = array();
     $tmp = field_get_items('commerce_line_item', $line_item[0], 'commerce_product');
     $product_ids[] = $tmp[0]['product_id'];
     $products = commerce_product_load_multiple($product_ids);
     $item = $products[0];
     if (property_exists($item, "csmdd32")) {
         $datosCS["CSMDD32"] = $item->csmdd32[LANGUAGE_NONE][0]["value"];
     }
     return array_merge($this->getMultipleProductsInfo(), $datosCS);
 }
 protected function getMultipleProductsInfo()
 {
     $order_lines = field_get_items('commerce_order', $this->datasources["order"], 'commerce_line_items');
     $line_item_ids = array();
     foreach ($order_lines as $order_line) {
         $line_item_ids[] = $order_line['line_item_id'];
     }
     $line_items = commerce_line_item_load_multiple($line_item_ids);
     $product_ids = array();
     $cant_prod = array();
     foreach ($line_items as $line_item) {
         $tmp = field_get_items('commerce_line_item', $line_item, 'commerce_product');
         $cant_prod[$tmp[0]['product_id']] = round($line_item->quantity);
         $product_ids[] = $tmp[0]['product_id'];
     }
     $products = commerce_product_load_multiple($product_ids);
     $code = array();
     $description = array();
     $name = array();
     $sku = array();
     $total = array();
     $quantity = array();
     $unit = array();
     foreach ($products as $item) {
         $code[] = $this->getCategoryArray($item);
         if (!empty($item->description)) {
             $desc = $item->description;
         } else {
             $desc = $item->title;
         }
         $desc = strip_tags($desc);
         $desc = TodoPago\Sdk::sanitizeValue($desc);
         $desc = substr($desc, 0, 50);
         $description[] = $desc;
         $name[] = substr($item->title, 0, 250);
         $sku[] = substr(empty($item->sku) ? $item->product_id : $item->sku, 0, 250);
         $total[] = number_format(commerce_currency_amount_to_decimal($item->commerce_price[LANGUAGE_NONE][0]["amount"], $item->commerce_price[LANGUAGE_NONE][0]["currency_code"]) * $cant_prod[$item->product_id], 2, ".", "");
         $quantity[] = $cant_prod[$item->product_id];
         $unit[] = number_format(commerce_currency_amount_to_decimal($item->commerce_price[LANGUAGE_NONE][0]["amount"], $item->commerce_price[LANGUAGE_NONE][0]["currency_code"]), 2, ".", "");
     }
     $productsData = array('CSITPRODUCTCODE' => join("#", $code), 'CSITPRODUCTDESCRIPTION' => join("#", $description), 'CSITPRODUCTNAME' => join("#", $name), 'CSITPRODUCTSKU' => join("#", $sku), 'CSITTOTALAMOUNT' => join("#", $total), 'CSITQUANTITY' => join("#", $quantity), 'CSITUNITPRICE' => join("#", $unit));
     return $productsData;
 }