log
This commit is contained in:
@@ -100,7 +100,6 @@ class OrderUpdateGm extends Command
|
|||||||
// Send the email to the admin with the details of the order log
|
// Send the email to the admin with the details of the order log
|
||||||
Mail::raw($log, function ($message, $orderupdated) {
|
Mail::raw($log, function ($message, $orderupdated) {
|
||||||
$message->to("log@fioredellavita.it");
|
$message->to("log@fioredellavita.it");
|
||||||
//$message->bcc('');
|
|
||||||
$message->subject(Mylog::getSubjectEmail("Ordini Aggiornati su GM:" . $orderupdated));
|
$message->subject(Mylog::getSubjectEmail("Ordini Aggiornati su GM:" . $orderupdated));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -50,14 +50,14 @@ class ProductUpdateGm extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$aggiornato = false;
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
ini_set("memory_limit", "512M");
|
ini_set("memory_limit", "512M");
|
||||||
$ora_update = Carbon::now();
|
$ora_update = Carbon::now();
|
||||||
$settingora = Setting::where('key', 'update_products')->first();
|
$settingora = Setting::where('key', 'update_products')->first();
|
||||||
$fromtime = str_replace('-', '', $settingora->value);
|
$fromtime = str_replace('-', '', $settingora->value);
|
||||||
|
|
||||||
$articles = Article::join(DB::raw('(SELECT IdArticolo, MAX(DataOra) AS data FROM T_WEB_Articoli GROUP BY IdArticolo) b'), function($join)
|
$articles = Article::join(DB::raw('(SELECT IdArticolo, MAX(DataOra) AS data FROM T_WEB_Articoli GROUP BY IdArticolo) b'), function ($join) {
|
||||||
{
|
|
||||||
$join->on('T_WEB_Articoli.IdArticolo', '=', 'b.IdArticolo')
|
$join->on('T_WEB_Articoli.IdArticolo', '=', 'b.IdArticolo')
|
||||||
->on('T_WEB_Articoli.DataOra', '=', 'b.data');
|
->on('T_WEB_Articoli.DataOra', '=', 'b.data');
|
||||||
})
|
})
|
||||||
@@ -97,18 +97,11 @@ class ProductUpdateGm extends Command
|
|||||||
$log2 = 'PRODOTTI AGGIORNATI' . "\n";
|
$log2 = 'PRODOTTI AGGIORNATI' . "\n";
|
||||||
$log3 = 'PRODOTTI NON INSERITI PER PROBLEMI SERVER' . "\n";
|
$log3 = 'PRODOTTI NON INSERITI PER PROBLEMI SERVER' . "\n";
|
||||||
|
|
||||||
foreach($articles as $article )
|
foreach ($articles as $article) {
|
||||||
{ try {
|
try {
|
||||||
$productsku = Product::where('sku', $article->IdArticolo)->first();
|
$productsku = Product::where('sku', $article->IdArticolo)->first();
|
||||||
//if(Gm_product::where('id_gm',$article->IdArticolo)->doesntExist())
|
//if(Gm_product::where('id_gm',$article->IdArticolo)->doesntExist())
|
||||||
if($productsku->count() == 0)
|
if ($productsku->count() == 0) {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$titolo = null;
|
$titolo = null;
|
||||||
$formato = null;
|
$formato = null;
|
||||||
$prodotti = null;
|
$prodotti = null;
|
||||||
@@ -125,24 +118,18 @@ class ProductUpdateGm extends Command
|
|||||||
foreach ($prodotti as $prodotto) {
|
foreach ($prodotti as $prodotto) {
|
||||||
if (strtolower($prodotto->name) === strtolower($titolo)) {
|
if (strtolower($prodotto->name) === strtolower($titolo)) {
|
||||||
$found_key = array_search('Autore libro', array_column($prodotto->attributes, 'name'));
|
$found_key = array_search('Autore libro', array_column($prodotto->attributes, 'name'));
|
||||||
if(array_diff($prodotto->attributes[$found_key]->options, $article->authors) === array_diff($article->authors, $prodotto->attributes[$found_key]->options ) )
|
if (array_diff($prodotto->attributes[$found_key]->options, $article->authors) === array_diff($article->authors, $prodotto->attributes[$found_key]->options)) {
|
||||||
{
|
|
||||||
$id = $prodotto->id;
|
$id = $prodotto->id;
|
||||||
$variations = Variation::all($prodotto->id);
|
$variations = Variation::all($prodotto->id);
|
||||||
foreach ($variations as $variation) {
|
foreach ($variations as $variation) {
|
||||||
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
|
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
|
||||||
if($variation->attributes[$found_key_version]->option == 'Nuovo')
|
if ($variation->attributes[$found_key_version]->option == 'Nuovo') {
|
||||||
{
|
|
||||||
$id = 0;
|
$id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$data1 = [
|
$data1 = [
|
||||||
|
|
||||||
@@ -298,10 +285,8 @@ class ProductUpdateGm extends Command
|
|||||||
$product = Product::find($id);
|
$product = Product::find($id);
|
||||||
$old_attributes = $product['attributes'];
|
$old_attributes = $product['attributes'];
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
foreach($old_attributes as $old_attribute)
|
foreach ($old_attributes as $old_attribute) {
|
||||||
{
|
if ($old_attribute->id <> 6) {
|
||||||
if($old_attribute->id <> 6)
|
|
||||||
{
|
|
||||||
|
|
||||||
$attributes[] = [
|
$attributes[] = [
|
||||||
'id' => $old_attribute->id,
|
'id' => $old_attribute->id,
|
||||||
@@ -342,6 +327,7 @@ class ProductUpdateGm extends Command
|
|||||||
$variation = Variation::create($id, $data1);
|
$variation = Variation::create($id, $data1);
|
||||||
}
|
}
|
||||||
$log .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . ' - ' . $versione . ' - ' . $variation['permalink'] . "\n";
|
$log .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . ' - ' . $versione . ' - ' . $variation['permalink'] . "\n";
|
||||||
|
$aggiornato = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'E-book':
|
case 'E-book':
|
||||||
@@ -352,22 +338,18 @@ class ProductUpdateGm extends Command
|
|||||||
$titolo = rtrim(str_ireplace('EPUB', '', $article->Titolo));
|
$titolo = rtrim(str_ireplace('EPUB', '', $article->Titolo));
|
||||||
|
|
||||||
$formato = 'Epub';
|
$formato = 'Epub';
|
||||||
|
} elseif ($article->DescrizioneFormato === 'Pdf') {
|
||||||
}
|
|
||||||
elseif($article->DescrizioneFormato === 'Pdf'){
|
|
||||||
$titolo = rtrim(str_ireplace('PDF', '', $article->Titolo));
|
$titolo = rtrim(str_ireplace('PDF', '', $article->Titolo));
|
||||||
|
|
||||||
$formato = 'PDF';
|
$formato = 'PDF';
|
||||||
|
} elseif ($article->DescrizioneFormato === 'Mobi') {
|
||||||
}
|
|
||||||
elseif($article->DescrizioneFormato === 'Mobi'){
|
|
||||||
$titolo = rtrim(str_ireplace('MOBI', '', $article->Titolo));
|
$titolo = rtrim(str_ireplace('MOBI', '', $article->Titolo));
|
||||||
|
|
||||||
|
|
||||||
$formato = 'Mobi';
|
$formato = 'Mobi';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$log1 .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . "\n";
|
$log1 .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . "\n";
|
||||||
|
$aggiornato = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$titolo = rtrim($titolo);
|
$titolo = rtrim($titolo);
|
||||||
@@ -387,23 +369,18 @@ class ProductUpdateGm extends Command
|
|||||||
foreach ($prodotti as $prodotto) {
|
foreach ($prodotti as $prodotto) {
|
||||||
if (strtolower($prodotto->name) === strtolower($titolo)) {
|
if (strtolower($prodotto->name) === strtolower($titolo)) {
|
||||||
$found_key = array_search('Autore libro', array_column($prodotto->attributes, 'name'));
|
$found_key = array_search('Autore libro', array_column($prodotto->attributes, 'name'));
|
||||||
if(array_diff($prodotto->attributes[$found_key]->options, $article->authors) === array_diff($article->authors, $prodotto->attributes[$found_key]->options ) )
|
if (array_diff($prodotto->attributes[$found_key]->options, $article->authors) === array_diff($article->authors, $prodotto->attributes[$found_key]->options)) {
|
||||||
{
|
|
||||||
$id = $prodotto->id;
|
$id = $prodotto->id;
|
||||||
$variations = Variation::all($prodotto->id);
|
$variations = Variation::all($prodotto->id);
|
||||||
foreach ($variations as $variation) {
|
foreach ($variations as $variation) {
|
||||||
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
|
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
|
||||||
if($variation->attributes[$found_key_version]->option == $formato)
|
if ($variation->attributes[$found_key_version]->option == $formato) {
|
||||||
{
|
|
||||||
$id = 0;
|
$id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$data1 = [
|
$data1 = [
|
||||||
|
|
||||||
@@ -540,18 +517,13 @@ class ProductUpdateGm extends Command
|
|||||||
|
|
||||||
|
|
||||||
$variation = Variation::create($idprodotto, $data1);
|
$variation = Variation::create($idprodotto, $data1);
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$versione = "Aggiunta versione";
|
$versione = "Aggiunta versione";
|
||||||
$product = Product::find($id);
|
$product = Product::find($id);
|
||||||
$old_attributes = $product['attributes'];
|
$old_attributes = $product['attributes'];
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
foreach($old_attributes as $old_attribute)
|
foreach ($old_attributes as $old_attribute) {
|
||||||
{
|
if ($old_attribute->id <> 6) {
|
||||||
if($old_attribute->id <> 6)
|
|
||||||
{
|
|
||||||
|
|
||||||
$attributes[] = [
|
$attributes[] = [
|
||||||
'id' => $old_attribute->id,
|
'id' => $old_attribute->id,
|
||||||
@@ -592,6 +564,7 @@ class ProductUpdateGm extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
$log .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . ' - ' . $versione . ' - ' . $variation['permalink'] . "\n";
|
$log .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . ' - ' . $versione . ' - ' . $variation['permalink'] . "\n";
|
||||||
|
$aggiornato = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Dvd':
|
case 'Dvd':
|
||||||
@@ -611,23 +584,18 @@ class ProductUpdateGm extends Command
|
|||||||
foreach ($prodotti as $prodotto) {
|
foreach ($prodotti as $prodotto) {
|
||||||
if (strtolower($prodotto->name) === strtolower($titolo)) {
|
if (strtolower($prodotto->name) === strtolower($titolo)) {
|
||||||
$found_key = array_search('Autore libro', array_column($prodotto->attributes, 'name'));
|
$found_key = array_search('Autore libro', array_column($prodotto->attributes, 'name'));
|
||||||
if(array_diff($prodotto->attributes[$found_key]->options, $article->authors) === array_diff($article->authors, $prodotto->attributes[$found_key]->options ) )
|
if (array_diff($prodotto->attributes[$found_key]->options, $article->authors) === array_diff($article->authors, $prodotto->attributes[$found_key]->options)) {
|
||||||
{
|
|
||||||
$id = $prodotto->id;
|
$id = $prodotto->id;
|
||||||
$variations = Variation::all($prodotto->id);
|
$variations = Variation::all($prodotto->id);
|
||||||
foreach ($variations as $variation) {
|
foreach ($variations as $variation) {
|
||||||
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
|
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
|
||||||
if($variation->attributes[$found_key_version]->option == 'DVD')
|
if ($variation->attributes[$found_key_version]->option == 'DVD') {
|
||||||
{
|
|
||||||
$id = 0;
|
$id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data1 = [
|
$data1 = [
|
||||||
@@ -767,18 +735,13 @@ class ProductUpdateGm extends Command
|
|||||||
|
|
||||||
|
|
||||||
$variation = Variation::create($idprodotto, $data1);
|
$variation = Variation::create($idprodotto, $data1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$versione = "Aggiunta versione";
|
$versione = "Aggiunta versione";
|
||||||
$product = Product::find($id);
|
$product = Product::find($id);
|
||||||
$old_attributes = $product['attributes'];
|
$old_attributes = $product['attributes'];
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
foreach($old_attributes as $old_attribute)
|
foreach ($old_attributes as $old_attribute) {
|
||||||
{
|
if ($old_attribute->id <> 6) {
|
||||||
if($old_attribute->id <> 6)
|
|
||||||
{
|
|
||||||
|
|
||||||
$attributes[] = [
|
$attributes[] = [
|
||||||
'id' => $old_attribute->id,
|
'id' => $old_attribute->id,
|
||||||
@@ -820,6 +783,7 @@ class ProductUpdateGm extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
$log .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . ' - ' . $versione . ' - ' . $variation['permalink'] . "\n";
|
$log .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . ' - ' . $versione . ' - ' . $variation['permalink'] . "\n";
|
||||||
|
$aggiornato = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -831,16 +795,13 @@ class ProductUpdateGm extends Command
|
|||||||
$titolo = rtrim($article->Titolo, 'STR');
|
$titolo = rtrim($article->Titolo, 'STR');
|
||||||
$titolo = rtrim(str_ireplace('streaming', '', $titolo));
|
$titolo = rtrim(str_ireplace('streaming', '', $titolo));
|
||||||
$formato = 'Streaming';
|
$formato = 'Streaming';
|
||||||
|
} elseif ($article->DescrizioneFormato === 'Download') {
|
||||||
}
|
|
||||||
elseif($article->DescrizioneFormato === 'Download'){
|
|
||||||
$titolo = rtrim($article->Titolo, 'VOD');
|
$titolo = rtrim($article->Titolo, 'VOD');
|
||||||
$titolo = rtrim(str_ireplace('download', '', $titolo));
|
$titolo = rtrim(str_ireplace('download', '', $titolo));
|
||||||
$formato = 'Download';
|
$formato = 'Download';
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log1 .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . "\n";
|
$log1 .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . "\n";
|
||||||
|
$aggiornato = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -863,23 +824,18 @@ class ProductUpdateGm extends Command
|
|||||||
$found_key = array_search('Autore libro', array_column($prodotto->attributes, 'name'));
|
$found_key = array_search('Autore libro', array_column($prodotto->attributes, 'name'));
|
||||||
|
|
||||||
|
|
||||||
if(array_diff($prodotto->attributes[$found_key]->options, $article->authors) === array_diff($article->authors, $prodotto->attributes[$found_key]->options ) )
|
if (array_diff($prodotto->attributes[$found_key]->options, $article->authors) === array_diff($article->authors, $prodotto->attributes[$found_key]->options)) {
|
||||||
{
|
|
||||||
$id = $prodotto->id;
|
$id = $prodotto->id;
|
||||||
$variations = Variation::all($prodotto->id);
|
$variations = Variation::all($prodotto->id);
|
||||||
foreach ($variations as $variation) {
|
foreach ($variations as $variation) {
|
||||||
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
|
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
|
||||||
if($variation->attributes[$found_key_version]->option == $formato)
|
if ($variation->attributes[$found_key_version]->option == $formato) {
|
||||||
{
|
|
||||||
$id = 0;
|
$id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data1 = [
|
$data1 = [
|
||||||
@@ -923,8 +879,7 @@ class ProductUpdateGm extends Command
|
|||||||
],
|
],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
if($id == 0)
|
if ($id == 0) {
|
||||||
{
|
|
||||||
$versione = 'Nuova versione';
|
$versione = 'Nuova versione';
|
||||||
$category = Category::where('name', $article->argomento);
|
$category = Category::where('name', $article->argomento);
|
||||||
if ($category->count() > 0) {
|
if ($category->count() > 0) {
|
||||||
@@ -1016,18 +971,13 @@ class ProductUpdateGm extends Command
|
|||||||
|
|
||||||
|
|
||||||
$variation = Variation::create($idprodotto, $data1);
|
$variation = Variation::create($idprodotto, $data1);
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$versione = "Aggiunta versione";
|
$versione = "Aggiunta versione";
|
||||||
$product = Product::find($id);
|
$product = Product::find($id);
|
||||||
$old_attributes = $product['attributes'];
|
$old_attributes = $product['attributes'];
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
foreach($old_attributes as $old_attribute)
|
foreach ($old_attributes as $old_attribute) {
|
||||||
{
|
if ($old_attribute->id <> 6) {
|
||||||
if($old_attribute->id <> 6)
|
|
||||||
{
|
|
||||||
|
|
||||||
$attributes[] = [
|
$attributes[] = [
|
||||||
'id' => $old_attribute->id,
|
'id' => $old_attribute->id,
|
||||||
@@ -1067,15 +1017,9 @@ class ProductUpdateGm extends Command
|
|||||||
$variation = Variation::create($id, $data1);
|
$variation = Variation::create($id, $data1);
|
||||||
}
|
}
|
||||||
$log .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . ' - ' . $versione . ' - ' . $variation['permalink'] . "\n";
|
$log .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . ' - ' . $versione . ' - ' . $variation['permalink'] . "\n";
|
||||||
|
$aggiornato = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$data1 = [
|
$data1 = [
|
||||||
@@ -1092,11 +1036,8 @@ class ProductUpdateGm extends Command
|
|||||||
$variation = Variation::update($idprodotto, $productsku['id'], $data1);
|
$variation = Variation::update($idprodotto, $productsku['id'], $data1);
|
||||||
|
|
||||||
$log2 .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . ' - Articolo aggiornato - ' . $variation['permalink'] . "\n";
|
$log2 .= $article->Titolo . ' - ' . $article->DescrizioneTipologia . ' - ' . $article->DescrizioneFormato . ' - Articolo aggiornato - ' . $variation['permalink'] . "\n";
|
||||||
|
$aggiornato = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$log3 .= $article->IdArticolo . ' - ' . $article->Titolo . "\n";
|
$log3 .= $article->IdArticolo . ' - ' . $article->Titolo . "\n";
|
||||||
@@ -1104,16 +1045,13 @@ class ProductUpdateGm extends Command
|
|||||||
}
|
}
|
||||||
$settingora->value = $ora_update;
|
$settingora->value = $ora_update;
|
||||||
$settingora->save();
|
$settingora->save();
|
||||||
|
if ($aggiornato) {
|
||||||
Log::channel('updateproducts')->notice($log . $log2 . $log1 . $log3);
|
Log::channel('updateproducts')->notice($log . $log2 . $log1 . $log3);
|
||||||
Log::channel('updateproducts')->notice('Fino a ' . $ora_update . "\n");
|
Log::channel('updateproducts')->notice('Fino a ' . $ora_update . "\n");
|
||||||
Mail::raw($loginizio . $log . $log2 . $log1 . $log3 . $logfine, function ($message) {
|
Mail::raw($loginizio . $log . $log2 . $log1 . $log3 . $logfine, function ($message) {
|
||||||
$message->to("log@fioredellavita.it");
|
$message->to("log@fioredellavita.it");
|
||||||
//$message->bcc('luca@pecos.it');
|
|
||||||
$message->subject(Mylog::getSubjectEmail("Inserim. nuovi prodotti"));
|
$message->subject(Mylog::getSubjectEmail("Inserim. nuovi prodotti"));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class ProductUpdateQta extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
$aggiornato = false;
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
ini_set("memory_limit", "512M");
|
ini_set("memory_limit", "512M");
|
||||||
$ora_update = Carbon::now();
|
$ora_update = Carbon::now();
|
||||||
@@ -95,6 +96,7 @@ class ProductUpdateQta extends Command
|
|||||||
} else {
|
} else {
|
||||||
Product::update($productsku['id'], $data1);
|
Product::update($productsku['id'], $data1);
|
||||||
}
|
}
|
||||||
|
$aggiornato = true;
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
//code error
|
//code error
|
||||||
@@ -108,13 +110,12 @@ class ProductUpdateQta extends Command
|
|||||||
$settingora->value = $ora_update;
|
$settingora->value = $ora_update;
|
||||||
$settingora->save();
|
$settingora->save();
|
||||||
|
|
||||||
|
if ($aggiornato) {
|
||||||
Log::channel('updateproductsqta')->notice($loginizio . $lognrprodotti . $logfine);
|
Log::channel('updateproductsqta')->notice($loginizio . $lognrprodotti . $logfine);
|
||||||
Mail::raw($loginizio . $lognrprodotti . $logfine, function ($message) {
|
Mail::raw($loginizio . $lognrprodotti . $logfine, function ($message) {
|
||||||
$message->to("log@fioredellavita.it");
|
$message->to("log@fioredellavita.it");
|
||||||
//$message->bcc('luca@pecos.it');
|
|
||||||
$message->subject(Mylog::getSubjectEmail("Aggiornam. Qtà Prodotti:"));
|
$message->subject(Mylog::getSubjectEmail("Aggiornam. Qtà Prodotti:"));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class ProductUpdateUsedGm extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
$aggiornato = false;
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
ini_set("memory_limit", "512M");
|
ini_set("memory_limit", "512M");
|
||||||
$ora_update = Carbon::now();
|
$ora_update = Carbon::now();
|
||||||
@@ -58,8 +59,7 @@ class ProductUpdateUsedGm extends Command
|
|||||||
$fromtime = str_replace('-', '', $settingora->value);
|
$fromtime = str_replace('-', '', $settingora->value);
|
||||||
|
|
||||||
|
|
||||||
$articles = Article::join(DB::raw('(SELECT IdArticolo, MAX(DataOra) AS data FROM T_WEB_Articoli GROUP BY IdArticolo) b'), function($join)
|
$articles = Article::join(DB::raw('(SELECT IdArticolo, MAX(DataOra) AS data FROM T_WEB_Articoli GROUP BY IdArticolo) b'), function ($join) {
|
||||||
{
|
|
||||||
$join->on('T_WEB_Articoli.IdArticolo', '=', 'b.IdArticolo')
|
$join->on('T_WEB_Articoli.IdArticolo', '=', 'b.IdArticolo')
|
||||||
->on('T_WEB_Articoli.DataOra', '=', 'b.data');
|
->on('T_WEB_Articoli.DataOra', '=', 'b.data');
|
||||||
})
|
})
|
||||||
@@ -103,16 +103,15 @@ class ProductUpdateUsedGm extends Command
|
|||||||
$log3 = 'PRODOTTI USATI NON INSERITI PER PROBLEMI SERVER' . "\n";
|
$log3 = 'PRODOTTI USATI NON INSERITI PER PROBLEMI SERVER' . "\n";
|
||||||
|
|
||||||
|
|
||||||
foreach($articles as $article)
|
foreach ($articles as $article) {
|
||||||
{ try {
|
try {
|
||||||
/*
|
/*
|
||||||
$settingdata = Setting::where('key','data_product_used')->first();
|
$settingdata = Setting::where('key','data_product_used')->first();
|
||||||
$settingdata->value = $article->data;
|
$settingdata->value = $article->data;
|
||||||
$settingdata->save();
|
$settingdata->save();
|
||||||
*/
|
*/
|
||||||
$productsku = Product::where('sku', $article->IdArticolo)->first();
|
$productsku = Product::where('sku', $article->IdArticolo)->first();
|
||||||
if($productsku->count() == 0)
|
if ($productsku->count() == 0) {
|
||||||
{
|
|
||||||
|
|
||||||
$titolo = null;
|
$titolo = null;
|
||||||
$formato = null;
|
$formato = null;
|
||||||
@@ -195,10 +194,8 @@ class ProductUpdateUsedGm extends Command
|
|||||||
|
|
||||||
$old_attributes = $product->attributes;
|
$old_attributes = $product->attributes;
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
foreach($old_attributes as $old_attribute)
|
foreach ($old_attributes as $old_attribute) {
|
||||||
{
|
if ($old_attribute->id <> 6) {
|
||||||
if($old_attribute->id <> 6)
|
|
||||||
{
|
|
||||||
|
|
||||||
$attributes[] = [
|
$attributes[] = [
|
||||||
'id' => $old_attribute->id,
|
'id' => $old_attribute->id,
|
||||||
@@ -239,18 +236,14 @@ class ProductUpdateUsedGm extends Command
|
|||||||
|
|
||||||
$log .= $article->Titolo . ' - ' . $article->Ean13 . " - " . $variation['permalink'] . "\n";
|
$log .= $article->Titolo . ' - ' . $article->Ean13 . " - " . $variation['permalink'] . "\n";
|
||||||
|
|
||||||
|
$aggiornato = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$data1 = [
|
$data1 = [
|
||||||
|
|
||||||
@@ -268,6 +261,8 @@ class ProductUpdateUsedGm extends Command
|
|||||||
//echo "Modificato " . $article->Titolo ."<br>";
|
//echo "Modificato " . $article->Titolo ."<br>";
|
||||||
$log2 .= $article->Titolo . ' - ' . $article->Ean13 . " - Articolo aggiornato - " . $variation['permalink'] . "\n";
|
$log2 .= $article->Titolo . ' - ' . $article->Ean13 . " - Articolo aggiornato - " . $variation['permalink'] . "\n";
|
||||||
|
|
||||||
|
$aggiornato = true;
|
||||||
|
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
@@ -278,18 +273,16 @@ class ProductUpdateUsedGm extends Command
|
|||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
//$log3 .= $article->IdArticolo . ' - '. $article->Titolo ."\n" ;
|
//$log3 .= $article->IdArticolo . ' - '. $article->Titolo ."\n" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$settingora->value = $ora_update;
|
$settingora->value = $ora_update;
|
||||||
$settingora->save();
|
$settingora->save();
|
||||||
|
if ($aggiornato) {
|
||||||
Log::channel('updateproductsused')->notice($log . $log2 . $log1 . $log3);
|
Log::channel('updateproductsused')->notice($log . $log2 . $log1 . $log3);
|
||||||
Log::channel('updateproductsused')->notice('Fino a ' . $ora_update . "\n");
|
Log::channel('updateproductsused')->notice('Fino a ' . $ora_update . "\n");
|
||||||
Mail::raw($loginizio . $log . $log2 . $log1 . $log3 . $logfine, function ($message) {
|
Mail::raw($loginizio . $log . $log2 . $log1 . $log3 . $logfine, function ($message) {
|
||||||
$message->to("log@fioredellavita.it");
|
$message->to("log@fioredellavita.it");
|
||||||
//$message->bcc('luca@pecos.it');
|
|
||||||
$message->subject(Mylog::getSubjectEmail("Inserim. nuovi prodotti Usati"));
|
$message->subject(Mylog::getSubjectEmail("Inserim. nuovi prodotti Usati"));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user