Пример #1
0
 /**
  * (non-PHPdoc)
  * @see Application\Controller.CrudController::listAction()
  */
 public function listAction()
 {
     $comboHeader = array('' => 'All');
     // 		$this->view->page = $page = $this->getRequest()->getParam('page') ?: 1;
     // 		$this->view->itemCode = $itemCode = $this->getRequest()->getParam('ItemCode');
     // 		$this->view->idProductGroup = $idProductGroup = $this->getRequest()->getParam('idProductGroup');
     // 		$this->view->idFamily = $idFamily = $this->getRequest()->getParam('idFamily');
     // 		$this->view->status = $status = $this->getRequest()->getParam('status');
     // 		$rotationStorageName = 'InventoryRotation';
     // 		$inventory = InventoryRotationQuery::create()->find();
     // 		$products = ProductQuery::create()
     // 		->whereAdd(Product::ITEM_CODE, $inventory->getDistinctItemCodes(), BaseQuery::IN)
     // 		->addAscendingOrderBy(Product::ITEM_CODE)
     // 		->find();
     // 		$rotationGenerator = new RotationGeneratorManager();
     // 		$rotationByKeyMother = $rotationGenerator
     // 		->generateRotationByKeyMother($inventory, $products);
     // 		$rotationByKeyMother = $abcParam!=''?$rotationByKeyMother->filterByAbc($abcParam):$rotationByKeyMother;
     // 		$rotationByKeyMother = $itemCode!=''?$rotationByKeyMother->filterByKeyMother($itemCode):$rotationByKeyMother;
     // 		$rotationByKeyMother = $idProductGroup!=''?$rotationByKeyMother->filterByProductGroup($idProductGroup):$rotationByKeyMother;
     // 		$rotationByKeyMother = ($idFamily != '' && $idProductGroup!='') ? $rotationByKeyMother->filterByFamily($idProductGroup, $idFamily) : $rotationByKeyMother;
     // 		$rotationByKeyMother = ($status != '') ? $rotationByKeyMother->filterByStatus($status) : $rotationByKeyMother;
     // 		$total = $rotationByKeyMother->count();
     // 		$this->view->rotationByKeyMother = $rotationByKeyMother
     // 		->paginate($page, $this->getMaxPerPage())
     // 		->getStock();
     $this->view->abc = RestockAbcClassQuery::create()->find();
     $this->view->total = $total;
     // 		$this->view->paginator = $this->createPaginator($total, $page);
     $this->view->productGroups = $comboHeader + ProductGroupQuery::create()->actives()->find()->toCombo();
     $this->view->families = $comboHeader;
     $this->view->statuses = $comboHeader + Product::$StatusFullName;
     $this->view->setTpl('Index');
     $this->view->contentTitle = $this->i18n->_('VIM List');
 }
Пример #2
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()));
 }
Пример #3
0
 public function exportToExcelAction()
 {
     $storage = $this->getStorageService();
     $params = $this->getRequest()->getParams();
     $colors = ColorQuery::create()->find();
     $brands = BrandQuery::create()->find();
     $productQuery = ProductQuery::create()->useFileCache()->filter($params);
     $productCollection = $productQuery->find();
     $i = 0;
     $freightFareCollection = FreightFareQuery::create()->find();
     $freightTypeCollection = FreightTypeQuery::create()->find();
     $customsTariffCodeCollection = CustomsTariffCodeQuery::create()->find();
     $incotermCollection = IncotermQuery::create()->find();
     $productGroupCollection = ProductGroupQuery::create()->find();
     $supplierCollection = $storage->getValue('suppliers');
     $currentProduct = $productCollection->read();
     $content = "\"Parent Code\",\"Item Code\",\"Item Name\",\"Product Group\",\"Brand\",\"Color\",\"VIM by color\",\"Status\",\"Default Fare\",\"Default Port\",\"Customs Code\",\"Percentage\",\"Catalog Collection\",\"Lead Time\",\"Target Price\",\"Incoterm\",\"Prefered Supplier\",\"Currency\",\"Carton Front\",\"Carton Height\",\"Carton Width\",\"Carton Weight\",\"Pieces per Master Carton\";\n";
     foreach ($productCollection as $product) {
         $freightFare = $product->getDefaultFreightFare() ? $freightFareCollection->getByPK($product->getDefaultFreightFare()) : new FreightFare();
         $freightFare = $freightFare ?: new FreightFare();
         $freightType = $freightFare->getIdFreightType() ? $freightTypeCollection->getByPk($freightFare->getIdFreightType()) : new FreightType();
         $freightType = $freightType ?: new FreightType();
         $customsTariffCode = $product->getIdCustomsTariffCode() ? $customsTariffCodeCollection->getByPK($product->getIdCustomsTariffCode()) : new CustomsTariffCode();
         $customsTariffCode = $customsTariffCode ?: new CustomsTariffCode();
         $incoterm = $product->getIdIncoterm() ? $incotermCollection->getByPk($product->getIdIncoterm()) : new Incoterm();
         $incoterm = $incoterm ?: new Incoterm();
         $supplier = $product->getIdSupplier() ? $supplierCollection->getByPK($product->getIdSupplier()) : new SapSupplier();
         $supplier = $supplier ?: new SapSupplier();
         $productGroup = $product->getIdProductGroup() ? $productGroupCollection->getByPK($product->getIdProductGroup()) : new ProductGroup();
         $productGroup = $productGroup ?: new ProductGroup();
         $status = array_flip(Product::$Status);
         $content .= $this->createCsvRow($product->getKeyMother());
         $content .= $this->createCsvRow($product->getItemCode());
         $content .= $this->createCsvRow($product->getItemName());
         $content .= $this->createCsvRow($productGroup->getName());
         $content .= $this->createCsvRow($brands->getByPkOrEmpty($product->getIdBrand())->getName());
         $content .= $this->createCsvRow($colors->getByCodeOrEmpty($product->getIdColor())->getName());
         $content .= $this->createCsvRow($product->getVim());
         $content .= $this->createCsvRow($status[$product->getStatus()]);
         $content .= $this->createCsvRow($freightFare->getUnitCost());
         $content .= $this->createCsvRow($freightType->getName() . '-' . $freightFare->getIdTransit());
         $content .= $this->createCsvRow($customsTariffCode->getName());
         $content .= $this->createCsvRow($customsTariffCode->getPercent());
         $content .= $this->createCsvRow($product->getCatalogYear());
         $content .= $this->createCsvRow($product->getLeadTime());
         $content .= $this->createCsvRow($product->getCost());
         $content .= $this->createCsvRow($incoterm->getName());
         $content .= $this->createCsvRow($supplier->getName());
         $content .= $this->createCsvRow($supplier->getCurrency());
         $content .= $this->createCsvRow($product->getMcFront());
         $content .= $this->createCsvRow($product->getMcHeight());
         $content .= $this->createCsvRow($product->getMcDepth());
         $content .= $this->createCsvRow($product->getMcWeight());
         $content .= $this->createCsvRow($product->getMcParts());
         $content .= ";\n";
         $i++;
     }
     $title = $this->i18n->_('Products Report');
     $filetmp = tempnam('product', 'csv');
     $filename = 'products_report.csv';
     $resource = fopen($filetmp, 'w+');
     if ($resource) {
         fwrite($resource, $content);
         fclose($resource);
         readfile($filetmp);
         header('Content-type: application/vnd.ms-excel');
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         die;
     } else {
         $this->setFlash('error', $this->i18n->_('The file cannot be downloaded'));
     }
 }
Пример #4
0
 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';
 }
Пример #5
0
 /**
  *
  * Enter description here ...
  */
 public function exportToExcelAction()
 {
     $post['id_product_group'] = urldecode($this->getRequest()->getParam('id_product_group'));
     $post['id_family'] = urldecode($this->getRequest()->getParam('id_family'));
     $post['status'] = $this->getRequest()->getParam('status');
     $families = FamilyQuery::create()->filter($post)->find();
     if (!$families->isEmpty()) {
         $i = 1;
         while ($family = $families->read()) {
             if (ProductGroupQuery::create()->whereAdd(ProductGroup::ID_PRODUCT_GROUP, $family->getIdProductGroup())->count()) {
                 $productGroup = ProductGroupQuery::create()->whereAdd(ProductGroup::ID_PRODUCT_GROUP, $family->getIdProductGroup())->findOne();
             } else {
                 $productGroup = new ProductGroup();
             }
             $data[$i] = array($productGroup->getCode() . '-' . $productGroup->getName(), $family->getName(), $family->getCode(), $family->getStatusName());
             $i++;
         }
         $header = array($this->i18n->_('Product Group'), $this->i18n->_('Family'), $this->i18n->_('Code'), $this->i18n->_('Status'));
         $title = $this->i18n->_('Family Report');
         $fileName = $this->i18n->_('Family_report');
         $tableColumnsWidth = array('medium', 'medium', '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("error", $this->i18n->_('No records'));
         $this->_redirect('family/list');
     }
 }
Пример #6
0
 /**
  * 
  */
 public function getListResultsAction()
 {
     $fields = $this->getRequest()->getParams();
     $fields['product_group'] = "%" . $fields['product_group'] . "%";
     $productGroups = ProductGroupQuery::create()->filter($fields)->findByPage($fields['page'], $this->getMaxPerPage());
     while ($productGroup = $productGroups->read()) {
         $productGroup->setName(utf8_encode($productGroup->getName()));
     }
     die(json_encode($productGroups->toArray()));
 }
Пример #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');
     }
 }
Пример #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;
 }