public function getPartMaster() { $eltrekaedi = new Eltrekaedi(); $file = $eltrekaedi->getPartMasterFile(); $em = $this->getDoctrine()->getManager(); if (($handle = fopen($file, "r")) !== FALSE) { $data = fgetcsv($handle, 100000, "\t"); //print_r($data); foreach ($data as $key => $attr) { $attrs[$key] = strtolower($attr); } while ($data = fgetcsv($handle, 100000, "\t")) { foreach ($data as $key => $val) { $attributes[$attrs[$key]] = $val; } $attributes["wholeprice"] = str_replace(",", ".", $attributes["wholeprice"]); $attributes["retailprice"] = str_replace(",", ".", $attributes["retailprice"]); $attributes["gross_weight_gr"] = str_replace(",", ".", $attributes["gross_weight_gr"]); $attributes["lenght_mm"] = str_replace(",", ".", $attributes["lenght_mm"]); $attributes["width_mm"] = str_replace(",", ".", $attributes["width_mm"]); $attributes["height_mm"] = str_replace(",", ".", $attributes["height_mm"]); $eltrekaedi = $this->getDoctrine()->getRepository('EdiBundle:Eltrekaedi')->findOneByPartno($attributes["partno"]); $q = array(); foreach ($attributes as $field => $val) { $q[] = "`" . $field . "` = '" . addslashes($val) . "'"; } @($eltrekaedi_id = (int) $eltrekaedi->id); if ($eltrekaedi_id == 0) { $sql = "replace eltrekaedi set id = '" . $eltrekaedi_id . "', " . implode(",", $q); $em->getConnection()->exec($sql); } } } }
public function getEltrekaPartMaster($entity) { return; set_time_limit(100000); $eltrekaedi = new Eltrekaedi(); $file = $eltrekaedi->getPartMasterFile(); //$file = 'http://195.144.16.7/EltrekkaEDI/Temp/Parts/RE4V1G9V.txt'; $em = $this->getDoctrine()->getManager(); if (($handle = fopen($file, "r")) !== FALSE) { $data = fgetcsv($handle, 100000, "\t"); foreach ($data as $key => $attr) { $attrs[$key] = strtolower($attr); } $i = 0; while ($data = fgetcsv($handle, 100000, "\t")) { //if ($i++ < 130000) continue; foreach ($data as $key => $val) { $attributes[$attrs[$key]] = trim(addslashes($val)); } $attributes["wholeprice"] = str_replace(",", ".", $attributes["wholeprice"]); $attributes["retailprice"] = str_replace(",", ".", $attributes["retailprice"]); $attributes["gross_weight_gr"] = str_replace(",", ".", $attributes["gross_weight_gr"]); $attributes["lenght_mm"] = str_replace(",", ".", $attributes["lenght_mm"]); $attributes["width_mm"] = str_replace(",", ".", $attributes["width_mm"]); $attributes["height_mm"] = str_replace(",", ".", $attributes["height_mm"]); if (@(!$ediedis[$entity["id"]])) { $ediedi = $this->getDoctrine()->getRepository('EdiBundle:Edi')->findOneById($entity["id"]); $ediedis[$entity["id"]] = $ediedi; } $ediedi = $ediedis[$entity["id"]]; $ediediitem = $this->getDoctrine()->getRepository('EdiBundle:EdiItem')->findOneBy(array("itemCode" => $attributes["partno"], "Edi" => $ediedi)); @($ediedi_id = (int) $ediediitem->id); echo $attributes["partno"] . " " . $ediedi_id . "<BR>"; if (@$ediedi_id == 0) { $sql = "replace partsbox_db.edi_item set " . "id = '" . $ediedi_id . "', " . "edi='" . $entity["id"] . "', " . "itemcode='" . $attributes["partno"] . "', " . "brand='" . $attributes["supplierdescr"] . "', " . "partno='" . $attributes["factorypartno"] . "', " . "description='" . $attributes["description"] . "', " . "dlnr='" . $attributes["tecdocsupplierno"] . "', " . "artnr='" . $attributes["tecdocpartno"] . "', " . "retailprice='" . $attributes["retailprice"] . "'"; $em->getConnection()->exec($sql); echo $sql . "<BR>"; $ediediitem = $this->getDoctrine()->getRepository('EdiBundle:EdiItem')->findOneBy(array("itemCode" => $attributes["partno"], "Edi" => $ediedi)); @($ediedi_id = (int) $ediediitem->id); } //$ediediitem->updatetecdoc(); $eltrekaedi = $this->getDoctrine()->getRepository('EdiBundle:Eltrekaedi')->findOneByPartno($attributes["partno"]); $q = array(); foreach ($attributes as $field => $val) { $q[] = "`" . $field . "` = '" . addslashes($val) . "'"; } @($eltrekaedi_id = (int) $eltrekaedi->id); //if ($eltrekaedi_id == 0) { $sql = "replace partsbox_db.eltrekaedi set id = '" . $eltrekaedi_id . "', ediitem = '" . $ediedi_id . "', " . implode(",", $q); $em->getConnection()->exec($sql); //} //if ($i++ > 30) return; } } }