· 6 years ago · Oct 12, 2019, 11:16 AM
1 $file = $request->file('xls');
2 $date = $request->get('date');
3 $api = $request->get('api');
4
5 $supliers = [50811, 48605, 49370, 48690, 51617, 51619, 29313, 46123];
6
7 if($api == '36.6')
8 $term_id = 52860;
9 else
10 $term_id = false;
11
12 $products = DB::connection('mysql2')
13 ->select("SELECT post_id FROM x9G5n_postmeta WHERE meta_value = 'outofstock'");
14
15
16 $arrIsbn = $this->getIsbn($file, $api);
17
18 foreach($products as $product){
19
20 $productIsbn = DB::connection('mysql2')
21 ->select("SELECT meta_value FROM x9G5n_postmeta WHERE post_id = ".$product->post_id." AND meta_key = 'isbnn'");
22
23 foreach ($productIsbn as $productIsbnFromMysql){
24
25 if($arrIsbn !== 'error find begin value'){
26
27 foreach($arrIsbn as $key => $value){
28
29
30 \Log::info($key);
31 \Log::info($productIsbnFromMysql->meta_value);
32
33 if($key == $productIsbnFromMysql->meta_value){
34
35
36 $object_id = DB::connection('mysql2')
37 ->select("SELECT post_id FROM x9G5n_postmeta WHERE meta_value = '".$key."'");
38
39 $terms = DB::connection('mysql2')
40 ->select("SELECT term_taxonomy_id FROM x9G5n_term_relationships WHERE object_id = '".$object_id[0]->post_id."'");
41
42 DB::connection('mysql2')->update("UPDATE x9G5n_postmeta SET meta_value = '".$arrIsbn[$key]."' where POST_ID = ".$object_id[0]->post_id." AND meta_key = '_regular_price'");
43 DB::connection('mysql2')->update("UPDATE x9G5n_postmeta SET meta_value = '100' where POST_ID = ".$object_id[0]->post_id." AND meta_key = '_stock'");
44 DB::connection('mysql2')->update("UPDATE x9G5n_postmeta SET meta_value = 'instock' where POST_ID = ".$object_id[0]->post_id." AND meta_key = '_stock_status'");
45 DB::connection('mysql2')->update("UPDATE x9G5n_postmeta SET meta_value = 'instock' where POST_ID = ".$object_id[0]->post_id." AND meta_key = 'stock_status'");
46
47 foreach($terms as $term){
48
49 if(in_array($term->term_taxonomy_id, $supliers)){
50
51 DB::connection('mysql2')
52 ->update("UPDATE x9G5n_term_relationships SET term_taxonomy_id = '".$term_id."' WHERE term_taxonomy_id = '".$term->term_taxonomy_id."'");
53
54 }
55
56 }
57
58
59 }
60
61 }
62
63 }
64
65 }
66
67 }