當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Product::getProductFromExportToSite方法代碼示例

本文整理匯總了PHP中app\models\Product::getProductFromExportToSite方法的典型用法代碼示例。如果您正苦於以下問題:PHP Product::getProductFromExportToSite方法的具體用法?PHP Product::getProductFromExportToSite怎麽用?PHP Product::getProductFromExportToSite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Product的用法示例。


在下文中一共展示了Product::getProductFromExportToSite方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request, History $historyModel, Cloud $cloudModel, Product $productModel, Purchase $purchaseModel)
 {
     if (isset($_POST['delete_all_flags'])) {
         if (!right('Import')) {
             abort(404);
         }
         $productModel->deleteAllFlags();
         Session::flash('message', GetMessages("SUCCESS_DELETE_FLAGS"));
         return redirect()->route('cloud.index');
     }
     if (isset($_POST['delete_all_export_list'])) {
         if (!right('Import')) {
             abort(404);
         }
         $productModel->deleteAllExport();
         Session::flash('message', GetMessages("SUCCESS_DELETE_FLAGS"));
         return redirect()->route('cloud.index');
     }
     if (isset($_POST['ajax'])) {
         if (!right('Import')) {
             abort(404);
         }
         Session::forget('idsNewProducts');
     }
     if (isset($_POST['export_site'])) {
         if (!right('Import')) {
             abort(404);
         }
         //pr($_POST);
         if (isset($_POST['field'])) {
             $products = $productModel->getProductFromExportToSite();
             if (count($products) > 0) {
                 $res = array();
                 $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'ВП ID');
                 $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Производитель');
                 $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Наменование');
                 if (isset($_POST['field']['GK'])) {
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'ID ГК');
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Цена ГК');
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Валюта ГК');
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Активность ГК');
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Яндекс ГК');
                 }
                 if (isset($_POST['field']['TV'])) {
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'ID ТВ');
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Цена ТВ');
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Валюта ТВ');
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Активность ТВ');
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Яндекс ТВ');
                 }
                 if (isset($_POST['field']['MK'])) {
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'ID МК');
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Цена МК');
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Валюта МК');
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Активность МК');
                     $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Яндекс МК');
                 }
                 $res[0][] = iconv('UTF-8', 'cp1251//TRANSLIT', 'Наличие');
                 $i = 1;
                 foreach ($products as $product) {
                     $res[$i][] = $product->id;
                     $res[$i][] = iconv('UTF-8', 'cp1251//TRANSLIT', $product->brand);
                     $res[$i][] = iconv('UTF-8', 'cp1251//TRANSLIT', $product->name);
                     if (isset($_POST['field']['GK'])) {
                         if (strpos($product->GK_price, '.')) {
                             $product->GK_price = str_replace('.', ',', $product->GK_price);
                             //заменяем точку на запятую, ибо эксель ебанутый((
                         }
                         if ($product->GK_currency == 'RUB') {
                             $product->GK_price = intval($product->GK_price);
                             //округляем, если валюта RUB
                         }
                         $res[$i][] = $product->GK_id;
                         $res[$i][] = $product->GK_price;
                         $res[$i][] = $product->GK_currency;
                         $res[$i][] = $product->GK_enabled;
                         $res[$i][] = $product->GK_yandex_enabled;
                     }
                     if (isset($_POST['field']['TV'])) {
                         if (strpos($product->TV_price, '.')) {
                             $product->TV_price = str_replace('.', ',', $product->TV_price);
                             //заменяем точку на запятую, ибо эксель ебанутый((
                         }
                         if ($product->TV_currency == 'RUB') {
                             $product->TV_price = intval($product->TV_price);
                             //округляем, если валюта RUB
                         }
                         $res[$i][] = $product->TV_id;
                         $res[$i][] = $product->TV_price;
                         $res[$i][] = $product->TV_currency;
                         $res[$i][] = $product->TV_enabled;
                         $res[$i][] = $product->TV_yandex_enabled;
                     }
                     if (isset($_POST['field']['MK'])) {
//.........這裏部分代碼省略.........
開發者ID:enotsokolov,項目名稱:vp_plus,代碼行數:101,代碼來源:CloudController.php

示例2: send

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function send($site_id)
 {
     $productModel = new Product();
     $toExport = $productModel->getProductFromExportToSite();
     if (!empty($toExport)) {
         switch ($site_id) {
             case 'GK':
                 $connect_GK = $this->connect($site_id);
                 $currentCurrency = $connect_GK->table('shop_currency')->select('code', 'rate')->get();
                 //придется получить курсы с сайта, увы :(
                 $_rates = array();
                 foreach ($currentCurrency as $curr) {
                     $_rates[$curr->code] = $curr->rate;
                 }
                 try {
                     foreach ($toExport as $product) {
                         if (!empty($product->GK_id)) {
                             /*Modificated*/
                             $product->in_stock == 1 ? $product->GK_in_stock = 999 : ($product->GK_in_stock = -999);
                             $product->GK_yandex_enabled == 1 ? $product->GK_yandex_enabled = 3 : ($product->GK_yandex_enabled = 2);
                             if ($product->GK_currency == 'RUB') {
                                 $product->GK_price = intval($product->GK_price);
                                 $product->GK_rub_price = intval($product->GK_price);
                             } else {
                                 $product->GK_rub_price = $product->GK_price * $_rates[$product->GK_currency];
                             }
                             /*Query*/
                             $connect_GK->table('shop_product as sp')->join('shop_product_skus as sps', 'sp.id', '=', 'sps.product_id')->where('sps.sku', $product->GK_id)->update(array('sp.status' => $product->GK_enabled, 'sp.count' => $product->GK_in_stock, 'sps.count' => $product->GK_in_stock, 'sp.type_id' => $product->GK_yandex_enabled, 'sp.price' => $product->GK_rub_price, 'sp.min_price' => $product->GK_rub_price, 'sp.max_price' => $product->GK_rub_price, 'sps.price' => $product->GK_price, 'sps.primary_price' => $product->GK_rub_price, 'sp.currency' => $product->GK_currency));
                         }
                     }
                 } catch (\Exception $e) {
                     echo "ERROR {$site_id}";
                     $this->disconnect($site_id);
                     exit;
                 }
                 break;
             case 'TV':
                 $connect_TV = $this->connect($site_id);
                 $currentCurrency = $connect_TV->table('diafan_shop_currency')->select('id', 'name', 'exchange_rate')->get();
                 $_rates = array();
                 foreach ($currentCurrency as $curr) {
                     $_rates[$curr->name] = array('id' => $curr->id, 'rate' => $curr->exchange_rate);
                 }
                 try {
                     foreach ($toExport as $product) {
                         if (!empty($product->TV_id)) {
                             /*Modificated*/
                             $product->TV_in_stock = $product->in_stock == 1 ? 100 : 0;
                             /*Query*/
                             $connect_TV->table('diafan_shop')->where('id', $product->TV_id)->update(array('act1' => $product->TV_enabled, 'show_yandex' => $product->TV_yandex_enabled));
                             $currentPrices = $connect_TV->table('diafan_shop_price')->where('good_id', $product->TV_id)->get();
                             if (!isset($currentPrices[0])) {
                                 $currentPrices[0] = new Collection();
                                 $currentPrices[0]->old_price = '';
                                 $currentPrices[0]->date_start = '';
                                 $currentPrices[0]->date_finish = '';
                                 $currentPrices[0]->discount = '';
                                 $currentPrices[0]->discount_id = '';
                                 $currentPrices[0]->person = '';
                                 $currentPrices[0]->role_id = '';
                                 $currentPrices[0]->import_id = '';
                                 $currentPrices[0]->trash = '';
                             }
                             $connect_TV->table('diafan_shop_price')->where('good_id', $product->TV_id)->delete();
                             $priceId = $connect_TV->table('diafan_shop_price')->insertGetId(array('good_id' => $product->TV_id, 'price' => $product->TV_price, 'old_price' => $currentPrices[0]->old_price, 'count_goods' => $product->TV_in_stock, 'price_id' => 0, 'date_start' => $currentPrices[0]->date_start, 'date_finish' => $currentPrices[0]->date_finish, 'discount' => $currentPrices[0]->discount, 'discount_id' => $currentPrices[0]->discount_id, 'person' => $currentPrices[0]->person, 'role_id' => $currentPrices[0]->role_id, 'currency_id' => $product->TV_currency == 'RUB' ? 0 : $_rates[$product->TV_currency]['id'], 'import_id' => $currentPrices[0]->import_id, 'trash' => $currentPrices[0]->trash));
                             if ($product->TV_currency != 'RUB') {
                                 $priceId = $connect_TV->table('diafan_shop_price')->insertGetId(array('good_id' => $product->TV_id, 'price' => $product->TV_price * $_rates[$product->TV_currency]['rate'], 'old_price' => $currentPrices[0]->old_price, 'count_goods' => $product->TV_in_stock, 'price_id' => 0, 'date_start' => $currentPrices[0]->date_start, 'date_finish' => $currentPrices[0]->date_finish, 'discount' => $currentPrices[0]->discount, 'discount_id' => $currentPrices[0]->discount_id, 'person' => $currentPrices[0]->person, 'role_id' => $currentPrices[0]->role_id, 'currency_id' => 0, 'import_id' => $currentPrices[0]->import_id, 'trash' => $currentPrices[0]->trash));
                             }
                             $connect_TV->table('diafan_shop_price')->where('good_id', $product->TV_id)->update(array('price_id' => $priceId));
                         }
                     }
                 } catch (\Exception $e) {
                     echo "ERROR {$site_id}";
                     $this->disconnect($site_id);
                     var_dump($e->getMessage());
                     var_dump($e->getLine());
                     exit;
                 }
                 break;
                 //                case 'TV':
                 //                    $connect_TV = $this->connect($site_id);
                 //
                 //                    $currentCurrency = $connect_TV->table('currency')->select('id', 'system_name')->get(); //придется получить курсы с сайта, увы :(
                 //
                 //                    $_rates = array();
                 //                    foreach($currentCurrency as $curr){
                 //                        $_rates[$curr->system_name] = $curr->id;
                 //                    }
                 //
                 //                    try {
                 //                        foreach($toExport as $product) {
                 //                            if (!empty($product->TV_id)) {
                 //
                 //                                /*Modificated*/
                 //                                $product->TV_enabled == 1 ? $product->TV_enabled = 'yes' : $product->TV_enabled = 0;
//.........這裏部分代碼省略.........
開發者ID:enotsokolov,項目名稱:vp_plus,代碼行數:101,代碼來源:External.php


注:本文中的app\models\Product::getProductFromExportToSite方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。