Example #1
0
 /**
  *
  */
 public function newKeyAction()
 {
     $post['NPD'] = $this->getRequest()->getParam('npd', '');
     $post['idProductGroup'] = $this->getRequest()->getParam('id_product_group', '');
     $post['idFamily'] = $this->getRequest()->getParam('id_family', '');
     $post['idSubfamily'] = $this->getRequest()->getParam('id_subfamily', '');
     $post['clvcomposition'] = $this->getRequest()->getParam('composition', '');
     $post['idBrand'] = $this->getRequest()->getParam('id_brand', '');
     $this->view->contentTitle = $this->i18n->_('Item Code');
     $this->view->NPDSheet = $NPDSheet = !empty($post['NPD']) ? NpdSheetQuery::create()->findByPKOrThrow($post['NPD'], $this->i18n->_("The NPDSheet with Id {$post['NPD']} does not exist.")) : new NpdSheet();
     $this->view->proceed = false;
     if ($this->getRequest()->isPost()) {
         $this->view->productGroup = $produtGroup = ProductGroupQuery::create()->findByPKOrThrow($post['idProductGroup'], $this->i18n->_("The ProductGroup with Id {$post['idProductGroup']} does not exist."));
         $this->view->family = $family = FamilyQuery::create()->findByPKOrThrow($post['idFamily'], $this->i18n->_("The Family with Id {$post['idFamily']} does not exist."));
         $this->view->subfamily = $subfamily = SubfamilyQuery::create()->findByPKOrThrow($post['idSubfamily'], $this->i18n->_("The Subfamily with Id {$post['idSubfamily']} does not exist."));
         $this->view->brand = $brand = BrandQuery::create()->findByPKOrThrow($post['idBrand'], $this->i18n->_("The Brand with Id {$post['idBrand']} does not exist."));
         $this->view->proceed = true;
     } else {
         if ($NPDSheet->getIdNpdSheet() > 0) {
             $this->view->productGroup = $produtGroup = ProductGroupQuery::create()->findByPKOrThrow($NPDSheet->getIdProductGroup(), $this->i18n->_("The ProductGroup with Id {$NPDSheet->getIdProductGroup()} does not exist."));
             //die("<pre>".print_r($produtGroup, true)."</pre>");
             $this->view->family = $family = $NPDSheet->getIdFamily() > 0 ? FamilyQuery::create()->findByPKOrThrow($NPDSheet->getIdFamily(), $this->i18n->_("The Family with Id {$NPDSheet->getIdFamily()} does not exist.")) : new Family();
             $this->view->subfamily = $subfamily = $NPDSheet->getIdSubfamily() > 0 ? SubfamilyQuery::create()->findByPKOrThrow($NPDSheet->getIdSubfamily(), $this->i18n->_("The Subfamily with Id {$NPDSheet->getIdSubfamily()} does not exist.")) : new Subfamily();
             //die($NPDSheet->getIdBrand());
             $this->view->brand = $brand = $NPDSheet->getIdBrand() > 0 ? BrandQuery::create()->findByPKOrThrow($NPDSheet->getIdBrand(), $this->i18n->_("The Brand with Id {$NPDSheet->getIdBrand()} does not exist.")) : new Brand();
         } else {
             $this->view->productGroup = $produtGroup = new ProductGroup();
             $this->view->family = $family = new Family();
             $this->view->subfamily = $subfamily = new Subfamily();
             $this->view->brand = $brand = new Brand();
         }
     }
     $productsFam = ProductQuery::create()->distinct()->addColumn(Product::ID_PRODUCT_GROUP)->fetchCol();
     $productGroupQuery = ProductGroupQuery::create();
     $productGroupQuery->where()->setOr();
     $productsFam = $productGroupQuery->whereAdd(ProductGroup::ID_PRODUCT_GROUP, $productsFam, ProductGroupQuery::IN)->whereAdd(ProductGroup::ID_PRODUCT_GROUP, $post['idProductGroup'])->addAscendingOrderBy(ProductGroup::CODE)->fetchAll();
     foreach ($productsFam as $key => $productFam) {
         if ($productFam['id_product_group'] == $post['idProductGroup']) {
             $productGroupIds = array("prevFamily" => $productsFam[$key - 1]['id_product_group'], "productFamily" => $productsFam[$key]['id_product_group'], "nextFamily" => $productsFam[$key + 1]['id_product_group']);
             break;
         }
     }
     //die("<pre>".print_r($productGroupIds, true)."</pre>");
     $wantedProducts = ProductQuery::create();
     $wantedProducts->where()->setOR();
     $seachProducts = $wantedProducts->addColumns(array(Product::ITEM_CODE, Product::ITEM_NAME, Product::STATUS, "U_Madre_09" => 'SUBSTRING(' . Product::ITEM_CODE . ', 0, 8)', Product::ID_COLOR, Product::ID_COLOR))->whereAdd(Product::ID_PRODUCT_GROUP, $productGroupIds['productFamily'])->whereAdd(Product::ID_PRODUCT_GROUP, $productGroupIds['prevFamily'])->whereAdd(Product::ID_PRODUCT_GROUP, $productGroupIds['nextFamily'])->addAscendingOrderBy(Product::ITEM_CODE)->fetchAll();
     $newProduct = array(array('ItemCode' => $produtGroup->getCode() . $family->getCode() . $subfamily->getCode() . $post['clvcomposition'] . $brand->getName(), 'ItemName' => $NPDSheet->getName() ? $NPDSheet->getName() : $this->i18n->_('Not set'), 'SWW' => 'H', 'U_Madre_09' => $produtGroup->getCode() . $family->getCode() . $subfamily->getCode() . $post['clvcomposition'], 'U_Color' => $colorCode, 'index' => true));
     //order total products
     $products = array_merge($seachProducts, $newProduct);
     usort($products, function ($a, $b) {
         return strcmp($a['ItemCode'], $b['ItemCode']);
     });
     // 		echo '<pre>';
     // 		print_r($seachProducts);
     // 		die;
     //die("<pre>".print_r($products, true)."</pre>");
     $prepend = $produtGroup->getCode() . $family->getCode() . $subfamily->getCode();
     $lastItem = $newProduct[0]['U_Madre_09'];
     $nextComposition = $post['clvcomposition'];
     foreach ($seachProducts as $key => $val) {
         if (strstr($val['U_Madre_09'], $newProduct[0]['U_Madre_09'])) {
             $this->view->proceed = false;
         }
         if (strstr($val['U_Madre_09'], $lastItem)) {
             $nextComposition += 1;
             if ($nextComposition % 2 == 0) {
                 $nextComposition += 1;
             }
             $lastItem = $prepend . $nextComposition;
         }
     }
     // 		echo $lastItem;die;
     foreach ($products as $key => $product) {
         if ($product['ItemCode'] == $newProduct[0]['ItemCode']) {
             $this->view->index = $key;
         }
     }
     $this->view->productGroups = $this->getProductGroup();
     $families = array("" => $this->i18n->_("Select a Family"));
     if ($family->getIdFamily() > 0) {
         $families += FamilyQuery::create()->whereAdd(Family::ID_PRODUCT_GROUP, $family->getIdProductGroup())->find()->toCombo();
     }
     $this->view->families = $families;
     $subfamilies = array("" => $this->i18n->_("Select a Subfamily"));
     if ($subfamily->getIdSubfamily() > 0) {
         $subfamilies += SubfamilyQuery::create()->whereAdd(Subfamily::ID_FAMILY, $subfamily->getIdFamily())->find()->toComboUTF8();
     } else {
         $subfamilies += SubfamilyQuery::create()->whereAdd(Subfamily::ID_FAMILY, $family->getIdFamily())->find()->toComboUTF8();
     }
     $this->getRequest()->getParam("pending_product") == true ? $pendingProduct = true : ($pendingProduct = false);
     $this->view->nextComposition = $nextComposition;
     $this->view->pendingProduct = $pendingProduct;
     $this->view->subfamilies = $subfamilies;
     $this->view->brands = $this->getBrands();
     $this->view->products = $products;
     $this->view->colors = ColorQuery::create()->find();
     $this->view->setTpl('../npd-sheet/Npd-key');
 }
 public function addSupplierAction()
 {
     //view information NPD
     $this->view->id = $idNpdSheet = $this->getRequest()->getParam('id');
     $this->view->contentTitle = 'Add Supplier';
     $this->generateUrl('npd', 'create');
     $this->view->setTpl("Add-supplier");
     $this->view->npd = $npdSheet = NpdSheetQuery::create()->findByPKOrThrow($idNpdSheet, $this->i18n->_("It does not exist the NpdSheet with id {$idNpdSheet}"));
     $family = FamilyQuery::create()->findByPK($npdSheet->getIdFamily());
     $this->view->family = $family->getName();
     if ($npdSheet->getIdSubfamily()) {
         $this->view->subfamily = SubfamilyQuery::create()->findByPK($npdSheet->getIdSubfamily())->getName();
     } else {
         $this->view->subfamily = $this->i18n->_("Any");
     }
     $this->view->productGroup = ProductGroupQuery::create()->findByPK($family->getIdProductGroup())->getName();
     $this->view->videos = FileQuery::create()->innerJoinNpdSheet()->whereAdd('File2NpdSheet.id_npd_sheet', $npdSheet->getIdNpdSheet())->whereAdd(File::TYPE, File::$typeFile["typeLink"])->find();
     $this->view->npdColors = ColorQuery::create()->innerJoinNpdSheet()->whereAdd('Color2NpdSheet.id_npd_sheet', $npdSheet->getIdNpdSheet())->find();
     $this->view->country = CountryQuery::create()->find()->toCombo();
     $this->view->npdSheetImages = NpdSheetQuery::getNpdSheetFileObjects($npdSheet->getIdNpdSheet(), File::$typeFile["typeImage"]);
     $this->view->npdSheetFiles = NpdSheetQuery::create()->addColumns(array("File.*"))->innerJoinFile()->whereAdd("NpdSheet." . NpdSheet::ID_NPD_SHEET, $npdSheet->getIdNpdSheet())->fetchAll();
     $this->view->file = $file = FileQuery::create()->innerJoinNpdSheet()->whereAdd('File2NpdSheet.id_npd_sheet', $npdSheet->getIdNpdSheet())->whereAdd(File::TYPE, File::$typeFile["typeFile"])->findOne();
     //Form add supplier
     $npdSuppliers = $npdSuppliers = NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SHEET, $idNpdSheet)->find();
     $allColors = array("" => "**  Select a Color  **") + ColorQuery::create()->actives()->find()->toCombo();
     //Videos from supplier
     foreach ($npdSuppliers as $npdSupplier) {
         //Get File Video for NPDSheetSupplier
         $NPDSheetSupplierFilesQuery = NpdSheetSupplierQuery::create()->addColumns(array("File.*"))->innerJoinFile()->whereAdd("NpdSheetSupplier." . NpdSheetSupplier::ID_NPD_SUPPLIER, $npdSupplier->getIdNpdSupplier())->fetchAll();
         $NPDSheetSupplierFiles[$npdSupplier->getIdNpdSupplier()] = $NPDSheetSupplierFilesQuery;
         $assignedColors = $this->getSupplierColors($npdSupplier->getIdNpdSupplier());
         $i = 0;
         foreach ($assignedColors->toCombo() as $idColor => $colorName) {
             $colors[$npdSupplier->getIdNpdSupplier()][$i]["options"] = $allColors + array($idColor => $colorName);
             $colors[$npdSupplier->getIdNpdSupplier()][$i]["selected"] = $idColor;
             $i++;
         }
         if (count($colors[$npdSupplier->getIdNpdSupplier()]) == 0) {
             $colors[$npdSupplier->getIdNpdSupplier()][0]["options"] = $allColors;
         }
         //Moq and price
         $npdMoqPriceQuery = SupplierBudgetQuery::create();
         $npdMoqPriceQuery->whereAdd(SupplierBudget::ID_NPD_SUPPLIER, $npdSupplier->getIdNpdSupplier());
         $npdMoqPrice[$npdSupplier->getIdNpdSupplier()] = $npdMoqPriceQuery->find();
     }
     if ($npdSuppliers->count() > 0) {
         $this->view->npdSuppliers = $npdSuppliers;
         $this->view->NPDSheetSupplierFiles = $NPDSheetSupplierFiles;
         //die(print_r($colors));
         $this->view->fileTypes = File::$typeFile;
         $this->view->colors = $colors;
         $this->view->npdMoqPrice = $npdMoqPrice;
     } else {
         $npdSuppliers = new stdClass();
         $npdSuppliers->couryard = new NpdSheetSupplier();
         $this->view->npdSuppliers = $npdSuppliers;
         $this->view->defaultColor = $allColors;
     }
     $suppliers = Application\Query\SapSupplierQuery::create()->find();
     $temporalSupplierQuery = TemporalSupplierQuery::create()->find();
     $temporalSupplierArray = array();
     $temporalSupplierNamesArray = array();
     while ($temporalSupplier = $temporalSupplierQuery->read()) {
         $temporalSupplierNamesArray[$temporalSupplier->getIdTemporalSap()] = $temporalSupplier->getIdTemporalSap() . ' - ' . $temporalSupplier->getName();
         $temporalSupplierArray[$temporalSupplier->getIdTemporalSap()] = $temporalSupplier->getName();
     }
     //     	$suppliersToAjax += $temporalSupplierArray;
     $this->view->supplierNames = $suppliers->toAutoCompleteCombo() + $temporalSupplierNamesArray;
     $this->view->supplierTabs = $suppliers->toCombo() + $temporalSupplierArray;
     $this->view->fobPorts = array("" => "Select Fob Port") + Application\Query\PortCustomQuery::create()->actives()->whereAdd('PortCustom.' . PortCustom::IS_DEPARTURE, 1)->find()->toCombo();
     $this->view->incoterms = array("" => "Select Incoterm") + \Application\Query\IncotermQuery::create()->find()->toCombo();
     $this->view->currencies = array("" => "Select Currency") + \Application\Query\CurrencyQuery::create()->find()->toCombo();
     $this->view->actionForm = 'create';
 }
Example #3
0
 public function getListResultsAction()
 {
     $params = $this->getRequest()->getParams();
     $filter['status'] = $params['status'];
     $idProductGroup = $params['id_product_group'];
     $idFamily = $params['id_family'];
     if ($idProductGroup != '') {
         $productGroupQuery = ProductGroupQuery::create()->whereAdd(ProductGroup::ID_PRODUCT_GROUP, $idProductGroup)->find();
     } else {
         $productGroupQuery = ProductGroupQuery::create()->find();
     }
     if ($idFamily != '') {
         $families = FamilyQuery::create()->whereAdd(Family::ID_PRODUCT_GROUP, $productGroupQuery->getPrimaryKeys(), FamilyQuery::IN)->whereAdd(Family::ID_FAMILY, $idFamily)->find();
     } else {
         $families = FamilyQuery::create()->whereAdd(Family::ID_PRODUCT_GROUP, $productGroupQuery->getPrimaryKeys(), FamilyQuery::IN)->find();
     }
     $subfamilies = SubfamilyQuery::create()->whereAdd(Subfamily::ID_FAMILY, $families->getPrimaryKeys(), SubfamilyQuery::IN)->filter($filter)->page($params['page'], $this->getMaxPerPage())->find();
     while ($subfamily = $subfamilies->read()) {
         $subfamily->setName(utf8_encode($subfamily->getName()));
     }
     die(json_encode($subfamilies->toArray()));
 }
Example #4
0
 /**
  * @return 
  */
 public function getIdProductGroup()
 {
     return FamilyQuery::create()->findByPK($this->idFamily)->getIdProductGroup();
 }
Example #5
0
 /**
  * 
  */
 public function getListResultsAction()
 {
     $fields = $this->getRequest()->getParams();
     $families = FamilyQuery::create()->filter($fields)->page($fields['page'], $this->getMaxPerPage())->find();
     while ($family = $families->read()) {
         $family->setName(utf8_encode($family->getName()));
     }
     die(json_encode($families->toArray()));
 }
 /**
  *
  * Enter description here ...
  */
 public function jsonCodeAction()
 {
     //Busca el id de familias que coincidan con $id
     $id = $this->getRequest()->getParam('idCategory');
     $category = FamilyQuery::create()->findByPKOrThrow($id, "It does not exist the category {$id}");
     $subcategoryQuery = \Application\Query\SubfamilyQuery::create()->whereAdd(\Application\Model\Bean\Subfamily::ID_FAMILY, $id)->addAscendingOrderBy(\Application\Model\Bean\Subfamily::ID_SUBFAMILY);
     //->findOne();
     if ($subcategoryQuery->count() > 0) {
         $subcategory = \Application\Query\SubfamilyQuery::create()->whereAdd(\Application\Model\Bean\Subfamily::ID_FAMILY, $id)->addAscendingOrderBy(\Application\Model\Bean\Subfamily::ID_SUBFAMILY)->findOne()->getCode();
     } else {
         $subcategory = 0;
     }
     die(json_encode(array($category->getCode(), $subcategory)));
 }
Example #7
0
 public function exportToExcelPendingProductAction()
 {
     $post['id_product_group'] = urldecode($this->getRequest()->getParam('id_product_group'));
     $post['reference'] = urldecode($this->getRequest()->getParam('reference'));
     $post['status'] = $this->getRequest()->getParam('status');
     $npdsheets = NpdSheetQuery::create()->filter($post)->addDescendingOrderBy(NpdSheet::ID_NPD_SHEET)->whereAdd(NpdSheet::STATUS, NpdSheet::$Status['Pending Product'])->find();
     if (!$npdsheets->isEmpty()) {
         $i = 1;
         while ($npdsheet = $npdsheets->read()) {
             $productGroup = ProductGroupQuery::create()->whereAdd(ProductGroup::ID_PRODUCT_GROUP, $npdsheet->getIdProductGroup())->findOne();
             $family = FamilyQuery::create()->whereAdd(Family::ID_FAMILY, $npdsheet->getIdFamily())->findOne();
             $subfamily = SubfamilyQuery::create()->whereAdd(Subfamily::ID_SUBFAMILY, $npdsheet->getIdSubfamily())->findOne();
             $npdSupplier = NpdSheetSupplierQuery::create()->innerJoinNpdSheet()->whereAdd('NpdSheetSupplier.id_npd_sheet', $npdsheet->getIdNpdSheet())->find()->getPrimaryKeys();
             if ($npdSupplier) {
                 $authorizedPrice = SupplierBudgetQuery::create()->innerJoinNpdSheetSupplier()->whereAdd('SupplierBudget.id_npd_supplier', $npdSupplier, Criteria::IN)->whereAdd('SupplierBudget.is_authorized', 1)->findOne();
             }
             if (!$authorizedPrice) {
                 $authorizedPrice = new SupplierBudget();
             }
             if (NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SUPPLIER, $authorizedPrice->getIdNpdSupplier())->count()) {
                 $npdSupplier = NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SUPPLIER, $authorizedPrice->getIdNpdSupplier())->findOne();
             } else {
                 $npdSupplier = null;
             }
             if ($npdSupplier) {
                 if (SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $npdSupplier->getIdSupplier())->count()) {
                     $supplier = SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $npdSupplier->getIdSupplier())->findOne()->getSupplierCardCodeWithCardName();
                 }
             }
             $data[$i] = array($npdsheet->getIdNpdSheet(), $npdsheet->getStatusName(), $npdsheet->getReference(), $npdsheet->getCreationDateAsZendDate()->get('YYYY-MM-dd'), $productGroup->getCode() . '-' . $productGroup->getName(), $family->getCode() . '-' . $family->getName(), $subfamily ? $subfamily->getCode() . '-' . $subfamily->getName() : $this->i18n->_('Not Available'), $npdsheet->getName(), $npdsheet->getPrice(), $authorizedPrice->getPrice(), $supplier ? $supplier : null);
             $i++;
         }
         $header = array($this->i18n->_('ID'), $this->i18n->_('Status'), $this->i18n->_('Reference'), $this->i18n->_('Creation date'), $this->i18n->_('Product Group'), $this->i18n->_('Family'), $this->i18n->_('Subfamily'), $this->i18n->_('Product'), $this->i18n->_('Target Price'), $this->i18n->_('Authorized Price'), $this->i18n->_('Prefered Supplier'));
         $title = $this->i18n->_('NPDs Report');
         $fileName = $this->i18n->_('Npds_report');
         $tableColumnsWidth = array('mini');
         $report = new SimpleListReport();
         $report->setTableTitle($title);
         $report->setTableHeaders($header);
         $report->setTableContent($data);
         $report->setFilename($fileName);
         $report->setTableColumnsWidth($tableColumnsWidth);
         $report->createSpreadsheet();
     } else {
         $filter = $this->createFilterForUrl($post);
         $this->setFlash("warning", $this->i18n->_('No records found'));
         $this->_redirect('npd-sheet/pending-product');
     }
 }
Example #8
0
 /**
  *
  * Gets all Products from SAP, searches the DB for the itemcode, then updates or creates
  */
 public function syncProductsAction()
 {
     $r = SapProductQuery::create()->whereAdd(SapProduct::INVNTITEM, "Y")->find();
     $errors = 0;
     $new = 0;
     $updated = 0;
     echo "<pre>";
     echo "Name, itemcode, clave madre, resultado, mensaje \n";
     while ($r->valid()) {
         $save = 0;
         $sapProduct = $r->read();
         echo "\"" . trim($sapProduct->getItemname()) . "\", " . $sapProduct->getItemcode() . ", " . $sapProduct->getUMadre9() . ", ";
         if (strlen($sapProduct->getItemcode()) != 11) {
             echo "1, Error! ItemCode invalido: len " . strlen($sapProduct->getItemcode()) . "\n";
             $errors++;
             continue;
         }
         $product = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $sapProduct->getItemcode(), ProductQuery::EQUAL)->findOne();
         if (!$product instanceof Product) {
             $product = new Product();
             $save = 1;
         }
         $brand = BrandQuery::create()->whereAdd(Brand::CODE, substr($sapProduct->getItemcode(), 7, 2))->findOne();
         if (!$brand instanceof Brand) {
             echo "2, Error! No Brand: " . substr($sapProduct->getItemcode(), 7, 2) . "\n";
             $errors++;
             continue;
         }
         $product->setIdBrand($brand->getIdBrand());
         $color = ColorQuery::create()->whereAdd(Color::CODE, substr($sapProduct->getItemcode(), 9, 2))->findOne();
         if (!$color instanceof Color) {
             echo "3, Error! No Color: " . substr($sapProduct->getItemcode(), 9, 2) . "\n";
             $errors++;
             continue;
         }
         $product->setIdColor($color->getIdColor());
         $customsTariffCode = CustomsTariffCodeQuery::create()->whereAdd(CustomsTariffCode::CODE, $sapProduct->getCstGrpCode())->findOne();
         if (!$customsTariffCode instanceof CustomsTariffCode) {
             echo "4, Error! No Tax Code: " . $sapProduct->getCstGrpCode() . "\n";
             $errors++;
             continue;
         }
         $product->setIdCustomsTariffCode($customsTariffCode->getIdCustomsTariffCode());
         $productGroup = ProductGroupQuery::create()->whereAdd(ProductGroup::CODE, substr($sapProduct->getItemcode(), 0, 2))->findOne();
         if (!$productGroup instanceof ProductGroup) {
             echo "5, Error! No ProductGroup: " . substr($sapProduct->getItemcode(), 0, 2) . "\n";
             $errors++;
             continue;
         }
         $product->setIdProductGroup($productGroup->getIdProductGroup());
         $family = FamilyQuery::create()->whereAdd(Family::CODE, substr($sapProduct->getItemcode(), 2, 1))->whereAdd(Family::ID_PRODUCT_GROUP, $productGroup->getIdProductGroup())->findOne();
         if (!$family instanceof Family) {
             echo "6, Error! No Family: " . substr($sapProduct->getItemcode(), 2, 1) . "\n";
             $errors++;
             continue;
         }
         $product->setIdFamily($family->getIdFamily());
         $subfamily = SubfamilyQuery::create()->whereAdd(Subfamily::CODE, substr($sapProduct->getItemcode(), 3, 1))->whereAdd(Subfamily::ID_FAMILY, $family->getIdFamily())->findOne();
         if (!$subfamily instanceof Subfamily) {
             echo "7, Error! No SubFamily: " . substr($sapProduct->getItemcode(), 3, 1) . "\n";
             $errors++;
             continue;
         }
         $product->setIdSubfamily($subfamily->getIdSubfamily());
         $product->setBuyUnit($sapProduct->getBuyUnitMsr());
         $product->setCost(0);
         $product->setIdCurrency(1);
         $product->setIdIncoterm(1);
         $product->setImportant(0);
         $product->setInventaryItem($sapProduct->getInvntItem() == 'Y' ? 1 : 0);
         $product->setInventoryUnit($sapProduct->getInvntryUom());
         $product->setItemCode($sapProduct->getItemcode());
         $product->setItemName($sapProduct->getItemname());
         $product->setKeyMother(substr($sapProduct->getItemcode(), 0, 7));
         $product->setMcDepth($sapProduct->getUMCProfundida());
         $product->setMcFront($sapProduct->getUMCFrente());
         $product->setMcHeight($sapProduct->getUMCAltura());
         $product->setMcParts($sapProduct->getUPzasXCaja());
         $product->setMcWeight($sapProduct->getUMCPeso());
         $product->setNumBuy($sapProduct->getNumInBuy());
         $product->setNumSales($sapProduct->getNumInSales());
         $product->setPurchaseItem($sapProduct->getPrchseItem() == 'Y' ? 1 : 0);
         $product->setPzaDepth($sapProduct->getUPzaprofu());
         $product->setPzaDiameter($sapProduct->getUPzadiametro());
         $product->setPzaFront($sapProduct->getUPzafrente());
         $product->setPzaHeight($sapProduct->getUPpzaaltura());
         $product->setPzaWeight($sapProduct->getUPesoXPza());
         $product->setRescue(0);
         $product->setSaiUnit($sapProduct->getSAlUnitMsr());
         $product->setSellItem($sapProduct->getSellItem() == 'Y' ? 1 : 0);
         $product->setStatus($sapProduct->getSWW());
         if ($save) {
             $this->getProductCatalog()->create($product);
             $new++;
         } else {
             $this->getProductCatalog()->update($product);
             $updated++;
         }
         echo "0, Ok! \n";
     }
     echo "\n\nTotals:\nErrors: " . $errors . "\nNew: " . $new . "\nUpdated: " . $updated;
     die;
 }