📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
e-ticaretv11.demodesign.com.tr
/
system
/
library
📝
easybulk.php
← Geri Dön
<?php class Easybulk { private $registry; private $db; private $session; private $url; private $config; private $log; private $customer; private $currency; private $tax; private $entegrasyon; private $server_url = 'http://ellc.com.tr:84/'; public function __construct($registry) { $this->db = $registry->get('db'); $this->config = $registry->get('config'); $this->session = $registry->get('session'); $this->url = $registry->get('url'); $this->config = $registry->get('config'); $this->log = $registry->get('log'); $this->customer = $registry->get('customer'); $this->currency = $registry->get('currency'); $this->tax = $registry->get('tax'); $this->entegrasyon = $registry->get('entegrasyon'); $this->registry = $registry; } public function client_connect($postdata = array()) { $curl = curl_init(); //for($i=0;$i<2000;$i++){ curl_setopt($curl, CURLOPT_URL, $this->server_url . 'updatebasic'); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($postdata)); curl_setopt($curl, CURLOPT_NOSIGNAL, 1); //curl_setopt($curl, CURLOPT_TIMEOUT_MS, 5000); // curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); return curl_exec($curl); } public function getUpdatableProduct($data = array()) { $sql = "select p2m.product_id from " . DB_PREFIX . "es_product_to_marketplace p2m left join " . DB_PREFIX . "product p on(p.product_id=p2m.product_id) where p.product_id is not null "; if (isset($data['market'])) { $sql .= " and (" . $data['market'] . " !='') "; } if (isset($data['limit'])) { $sql .= "limit " . $data['start'] . "," . $data['limit'] . ""; } try { $query = $this->db->query($sql); if ($query->num_rows) { return $query->row; } else { return false; } } catch (Exception $exception) { echo $exception->getMessage(); } } public function create_request($code, $product_code,$sale_price,$list_price,$quantity,$product_id,$variant_id, $service_type) { try { $this->db->query("insert into " . DB_PREFIX . "es_request SET code='" . $code . "', product_code='" . $product_code . "', sale_price='" . $sale_price. "',list_price='" . $list_price . "', quantity='" . $quantity . "', product_id='" . $product_id . "', variant_id='" . $variant_id . "',service_type='" . $service_type . "',date_added=NOW() "); return $this->db->getLastId(); }catch (Exception $exception){ echo $exception->getMessage(); } } public function getUpdatableProductTotal($data = array()) { $sql = "select count(*) as total from " . DB_PREFIX . "es_product_to_marketplace p2m left join " . DB_PREFIX . "product p on( p.product_id=p2m.product_id ) where p.product_id is not null "; if (isset($data['market'])) { $sql .= " and (" . $data['market'] . " !='' ) "; } $query = $this->db->query($sql); return $query->row['total']; } public function updateAfterBasicUpdate($data,$marketplace_data) { if ($data['status']) { $main_product_info = $this->entegrasyon->getProduct($data['product_id']); $marketplace_data['price'] = number_format($data['sale_price'],2); $marketplace_data['sale_status']=$main_product_info['quantity'] ? 1:0; // $marketplace_data['commission'] = $data['commission']; //print_r($marketplace_data); //return ; $this->entegrasyon->addMarketplaceProduct($data['product_id'], $marketplace_data, $data['code']); $json['status'] = true; /* if ($mode) { $json['message'] = $product_info['name'] . ' tüm özellikleri güncellendi'; } else { $json['message'] = $product_info['name'] . ' stok ve fiyatı güncellendi'; }*/ } else { $error = $this->entegrasyon->getError($data['product_id'], $data['code']); if ($error) { $this->entegrasyon->updateError($data['product_id'], $data['code'], 2, implode(',',$data['message'])); } else { $this->entegrasyon->addError($data['product_id'], $data['code'], 2, implode(',',$data['message'])); } $json['status'] = false; // $json['message'] = $product_info['name'] . ' - ' . $result['message']; } return $json; } public function createUpdateData($product_id, $code) { $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 (true) { 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; } }
💾 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