📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
e-ticaretv11.demodesign.com.tr
/
catalog
/
controller
/
api
📝
notejs.php
← Geri Dön
<?php class ControllerApiNotejs extends Controller { private $request_limit = 100; private $created_products = 0; private $debug = false; private $lastProductIndex = 0; public function __construct($registry) { parent::__construct($registry); $registry->set('easybulk', new Easybulk($registry)); } public function update_products_fast() { // $this->db->query("truncate table " . DB_PREFIX . "es_request"); // $this->db->query("truncate table " . DB_PREFIX . "es_callback_result"); $service = 'update_basic'; $this->load->model('entegrasyon/general'); $code = $this->request->get['code']; if (isset($this->request->get['request_limit'])) { $this->request_limit = $this->request->get['request_limit']; } if (isset($this->request->get['last_product_index'])) { $this->lastProductIndex = $this->request->get['last_product_index']; } else { $this->lastProductIndex = 0; } if (isset($this->request->get['debug'])) { $this->debug = true; } $marketPlace = $this->model_entegrasyon_general->getMarketPlace($code); // echo "Son Güncelleme Tarihi=".$last_update_date.'<br>'; $page = 0; $limit = 1; $start = 0; //$post_data[]=array(); $baslangic = microtime(TRUE); $itemCount = 0; // for($a=0;$a<$total_page;$a++){ $start = 0; $filter_data['market'] = $code; $marketplace_total_products = $this->easybulk->getUpdatableProductTotal($filter_data); $market_update_data = array(); for ($i = $this->lastProductIndex; $i < $marketplace_total_products; $i++) { $filter_data = array(); $filter_data['market'] = $code; $filter_data['limit'] = 1; $filter_data['start'] = $i; $marketplace_product = $this->easybulk->getUpdatableProduct($filter_data); $updatable_products = $this->createUpdateData($marketplace_product['product_id'], $code); if ($this->created_products + $this->totalnow <= $this->request_limit) { $market_update_data = array_merge($market_update_data, $updatable_products); } else { // echo 'last product=' . $i.'<br>'; break; } } $postdata = array( "code" => $marketPlace['code'], "service" => $service, "callback_url" => HTTPS_SERVER . "index.php?route=entegrasyon/callback/updatebasic", "domain_marketplace_id" => $marketPlace['domain_marketplace_id'], "data" => $market_update_data ); // print_r($postdata); // echo count($market_update_data) . ' Adet Ürün Gönderildi!<br>'; // echo $this->total_products; // return; $bitis = microtime(TRUE); $time_t = ($bitis - $baslangic) * 1000; $time_t = round($time_t, 5); // echo 'Bu sayfa opencart tarafında ' . round($time_t/1000) . ' saniyede yüklendi.=====<br>'; $baslangic = microtime(TRUE); if ($this->debug) { print_r($postdata); return; } $result = $this->easybulk->client_connect($postdata, $service); $bitis = microtime(TRUE); $time_t = ($bitis - $baslangic) * 100; $time_t = round($time_t, 5); // echo 'Bu sayfa sunucu tarafında ' . $time_t . ' saniyede yüklendi.'; echo json_encode(array('total' => $marketplace_total_products, 'last_product_id' => $i, 'total_updated' => $i)); /* if($i<$marketplace_total_products){ echo '<meta http-equiv="refresh" content="1; url=index.php?route=api/notejs/update_products_fast&code='.$code.'&request_limit='.$this->request_limit.'&last_product_index='.$i.'">'; }else { echo 'Tüm ürünler güncellendi'; } */ } private $totalnow = 0; public function createUpdateData($product_id, $code) { $this->totalnow = 0; $market_update_data = array(); $product_info = $this->entegrasyon->getProductForUpdate2($code, $product_id); $product_info['model'] = $this->config->get($code . '_setting_model_prefix') . $product_info['model']; if (isset($product_info['variants']['variants'])) { if (($this->created_products + count($product_info['variants']['variants'])) < $this->request_limit) { foreach ($product_info['variants']['variants'] as $variant) { if ($code == 'hb' || $code == 'cs') { $product_code = $variant['model']; } else if ($code == 'ty') { $product_code = $variant['barcode']; } else { $product_code = $variant['model']; } $upp_data = array( "req_id" => $this->easybulk->create_request($code, $product_code, $product_info['sale_price'], $product_info['list_price'], $variant['quantity'], $product_info['product_id'], $variant['variant_id'], 2), "name" => $product_info['name'], 'varyant_group_id' => $product_info['model'], "quantity" => $variant['quantity'] < 0 ? 0 : $variant['quantity'], "sale_price" => $product_info['sale_price'] + $variant['price'], 'list_price' => $product_info['list_price'], 'shipping_time' => $product_info['defaults']['shipping_time'] ? $product_info['defaults']['shipping_time'] : 3, 'maximum_purchase' => $product_info['defaults']['maximum_order'] ? $product_info['defaults']['maximum_order'] : 5 ); if ($code == 'n11') { $upp_data['product_code'] = $product_info['model'] . $variant['prefix']; } else { $upp_data['product_code'] = $product_code; } $market_update_data[] = $upp_data; // echo $this->created_products.'<br>'; $this->created_products++; } } else { $this->totalnow = count($product_info['variants']['variants']); //$this->created_products += count($product_info['variants']['variants']); return $market_update_data; } } else { if ($this->created_products + 1 <= $this->request_limit) { //HB,TY,CS,EPTT $product_code = $product_info['model']; if ($code == 'ty') { $market_data = unserialize($product_info[$code]); if ($market_data) { $product_code = $market_data['barcode']; } else { $product_code = $product_info['model']; } } $market_update_data[] = array( "req_id" => $this->easybulk->create_request($code, $product_code, $product_info['sale_price'], $product_info['list_price'], $product_info['quantity'], $product_info['product_id'], 0, 2), 'product_code' => $product_code, 'varyant_group_id' => $product_code, "quantity" => $product_info['quantity'] < 0 ? 0 : $product_info['quantity'], "sale_price" => $product_info['sale_price'], 'list_price' => $product_info['list_price'], 'shipping_time' => $product_info['defaults']['shipping_time'] ? $product_info['defaults']['shipping_time'] : 3, 'maximum_purchase' => $product_info['defaults']['maximum_order'] ? $product_info['defaults']['maximum_order'] : 5 ); $this->created_products++; } } return $market_update_data; } public function check_callback() { $result = $this->db->query("select * from " . DB_PREFIX . "es_request"); print_r($result->rows); } public function empty_all_request() { $result = $this->db->query("truncate table " . DB_PREFIX . "es_request"); echo 'all data has been deleted'; } public function update_after_update() { $products = $this->config->get('easyxml_updated_products'); $service = 'update_basic'; $this->load->model('entegrasyon/general'); $marketPlaces=$this->model_entegrasyon_general->getMarketPlaces(); //print_r($products);return; if($products) { foreach ($marketPlaces as $marketPlace) { if($marketPlace['status']) { $market_update_data = array(); $code = $marketPlace['code']; foreach ($products as $product) { $updatable_products = $this->createUpdateData($product, $code); if ($this->created_products + $this->totalnow <= $this->request_limit) { $market_update_data = array_merge($market_update_data, $updatable_products); } } if ($market_update_data) { $postdata = array( "code" => $marketPlace['code'], "service" => $service, "callback_url" => HTTPS_SERVER . "index.php?route=entegrasyon/callback/updatebasic", "domain_marketplace_id" => $marketPlace['domain_marketplace_id'], "data" => $market_update_data ); $result = $this->easybulk->client_connect($postdata, $service); } // print_r($postdata); } } // return; echo count($products).'Adet ürün güncellendi! Güncellenen ürünler'; print_r($products); $this->entegrasyon->deleteSetting('easyxml'); }else { echo 'güncellenecek Ürün bulunamadı!'; } } }
💾 Kaydet
İptal
📝 Yeniden Adlandır
İptal
Kaydet
🔐 Dosya İzinleri (chmod)
İzin Değeri:
Hızlı Seçim:
777
755
644
600
777
= Herkes okur/yazar/çalıştırır
755
= Sahip tam, diğerleri okur/çalıştırır
644
= Sahip okur/yazar, diğerleri okur
600
= Sadece sahip okur/yazar
İptal
Uygula