From 0dd72f04a07805a4bb075510ee0e8330f19afe9e Mon Sep 17 00:00:00 2001 From: paoloar77 Date: Mon, 17 Jun 2024 15:09:49 +0200 Subject: [PATCH] aa --- app/CustomFuncPao.php | 32 ++++++++++++++++++++------------ app/Services/ProductLogger.php | 2 ++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/CustomFuncPao.php b/app/CustomFuncPao.php index fcb8edc4..817e85f1 100644 --- a/app/CustomFuncPao.php +++ b/app/CustomFuncPao.php @@ -416,6 +416,7 @@ function setProductFromGM($article, $initlog, ProductLogger $passproductLogger) $preorder = true; try { + $productLogger->addlog('') $productsku = Product::where('sku', $article->IdArticolo)->first(); //if(Gm_product::where('id_gm',$article->IdArticolo)->doesntExist()) if ($productsku->count() == 0) { @@ -1366,12 +1367,13 @@ function setProductFromGM($article, $initlog, ProductLogger $passproductLogger) } } } catch (\Exception $e) { - $productLogger->addLog('server_issues',$article->IdArticolo . ' - ' . $article->Titolo . "\n"); + $productLogger->addLog('server_issues', $article->IdArticolo . ' - ' . $article->Titolo . "\n"); } } -function updateArticoloFromGM($idarticolo) { +function updateArticoloFromGM($idarticolo) +{ $productLogger = new ProductLogger(""); $articles = Article::where('IdArticolo', $idarticolo) @@ -1385,17 +1387,23 @@ function updateArticoloFromGM($idarticolo) { ->orderBy('dataOra', 'desc') ->get(); - - foreach ($articles as $article) { - // setProductFromGM($article, false, $productLogger); + if ($articles->count() > 0) { + $article = $articles[0]; + } else { + $article = null; } - $str = "Concatena "; - $str .= getarraystr($articles); + if ($article) { + setProductFromGM($article, false, $productLogger); - $str .= $productLogger->concatenateLogs(); + $str = "Concatena: "; + $str .= getarraystr($article); - - return $str; - -} \ No newline at end of file + $str .= $productLogger->concatenateLogs(); + + return $str; + } else { + return "Articolo non trovato"; + } + +} diff --git a/app/Services/ProductLogger.php b/app/Services/ProductLogger.php index d52d025e..e0d58aca 100644 --- a/app/Services/ProductLogger.php +++ b/app/Services/ProductLogger.php @@ -27,6 +27,8 @@ class ProductLogger if ($this->settingOra) { $this->logs['start'] = 'Inizio da ' . $this->settingOra . "\n"; $this->logs['end'] = 'Fino a ' . $oraUpdate->toDateTimeString() . "\n"; + } else { + $this->logs['start'] = 'Iniziato: ' . $oraUpdate->toDateTimeString() . "\n"; } $this->logs['inserted'] = 'PRODOTTI INSERITI' . "\n"; $this->logs['not_inserted'] = 'EVENTUALI PRODOTTI NON INSERITI' . "\n";