Advertisement
Guest User

impor_pro

a guest
Nov 23rd, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.88 KB | None | 0 0
  1. <?php
  2. require "clientes.php";
  3. require "producto.php";
  4. require __DIR__ . '/vendor/autoload.php';
  5. use Automattic\WooCommerce\Client;
  6. // obtengo las categorias del woocommerce
  7. $woocommerce = new Client(
  8.     'http://01.gamerstore.com.uy/',
  9.     'ck_2468a2a9dd002c173f8fb256b7ee37c752871735',
  10.     'cs_62b28a111193cc0709a170ec83cda5b159164344',
  11.     [
  12.         'wp_api' => true,
  13.         'version' => 'wc/v1',
  14.     ]
  15. );
  16. $categorias =  $woocommerce->get('products/categories');
  17. // fin categorias
  18. try {
  19.     $soapURL = "http://www.unicom.com.uy/WEB_Services_V2/Unicom.dll/wsdl/IP_Articulos" ;
  20.     $soapParameters = [
  21.         'trace' => 1,
  22.         'exceptions' => true,
  23.     ];
  24.    // obtengo las categorias del webservice
  25.     $soapClient = new SoapClient($soapURL, $soapParameters);
  26.     $soapFunction = "Grupos_Articulos";
  27.     $soapFunctionParameters = [
  28.         'Usuario' => 'Gamer Store',
  29.         'Password' => 'Charlote5011',
  30.         'UsuarioSOAP' => 'FRGS58%',
  31.          'Grupo_Padre' => ''
  32.     ];
  33.     $cat_s = $soapClient->__soapCall($soapFunction, $soapFunctionParameters);
  34. // obtengo productos por categorias del webservice
  35.     $data1 = array();
  36.     foreach ($cat_s as $key){
  37.     $soapClient = new SoapClient($soapURL, $soapParameters);
  38.     $soapFunction = "Lista_Articulos";
  39.     $soapFunctionParameters = [
  40.         'Usuario' => 'Gamer Store',
  41.         'Password' => 'Charlote5011',
  42.         'UsuarioSOAP' => 'FRGS58%',
  43.         'Filtros' => [
  44.             'Palabras' => '',
  45.             'CodigoGrupo' => $key->CodigoGrupo,
  46.             'CodigoMarca' => '',
  47.             'Solo_Modificados_desde' => '',
  48.             'Rango_informe' => ''
  49.         ],
  50.     ];
  51.  
  52.     $soapResult = $soapClient->__soapCall($soapFunction, $soapFunctionParameters);
  53. }
  54. array_push($data1,$soapResult);
  55. //
  56. $woocommerce = new Client(
  57.     'http://01.gamerstore.com.uy/',
  58.     'ck_2468a2a9dd002c173f8fb256b7ee37c752871735',
  59.     'cs_62b28a111193cc0709a170ec83cda5b159164344',
  60.     [
  61.         'wp_api' => true,
  62.         'version' => 'wc/v1',
  63.     ]
  64. );
  65.  
  66. foreach($data1 as $key => $val){
  67.     $cat= Categoria($val->CodS);
  68.     $img= foto($val->CodS);
  69.     $precioi = number_format($val->Costo,2);
  70.     $pdescuento = $precioi - ($precioi* 0.20);
  71.     $data2 = [
  72.     'name' => $val->Producto,
  73.     'type' => 'simple',
  74.     'sku'  => $val->CodS,
  75.     'price'  => number_format($val->Costo,2),
  76.     //descuento del 20%
  77.     'regular_price' => number_format($pdescuento,2),
  78.     'sale_price'  => number_format($pdescuento,2),
  79.     'description' => $val->Descripcion,
  80.     'short_description' => $val->Producto,
  81.    
  82.     'categories' => [
  83.         [
  84.             'id' => $cat
  85.         ],
  86.        
  87.        
  88.         [
  89.             'id' => 14
  90.         ]
  91.     ],
  92.     'images' => [
  93.         [
  94.             'src' => 'http://test.gamerstore.com.uy/img/'.$img.'.png',
  95.             'position' => 0
  96.         ]
  97.     ]
  98. ];
  99.  
  100. $woocommerce->post('products', $data2);
  101.  
  102. }
  103. } catch (Exception $e) {
  104.     echo "Exception Error: ".$e->getMessage();
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement