Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require "clientes.php";
- require "producto.php";
- require __DIR__ . '/vendor/autoload.php';
- use Automattic\WooCommerce\Client;
- // obtengo las categorias del woocommerce
- $woocommerce = new Client(
- 'http://01.gamerstore.com.uy/',
- 'ck_2468a2a9dd002c173f8fb256b7ee37c752871735',
- 'cs_62b28a111193cc0709a170ec83cda5b159164344',
- [
- 'wp_api' => true,
- 'version' => 'wc/v1',
- ]
- );
- $categorias = $woocommerce->get('products/categories');
- // fin categorias
- try {
- $soapURL = "http://www.unicom.com.uy/WEB_Services_V2/Unicom.dll/wsdl/IP_Articulos" ;
- $soapParameters = [
- 'trace' => 1,
- 'exceptions' => true,
- ];
- // obtengo las categorias del webservice
- $soapClient = new SoapClient($soapURL, $soapParameters);
- $soapFunction = "Grupos_Articulos";
- $soapFunctionParameters = [
- 'Usuario' => 'Gamer Store',
- 'Password' => 'Charlote5011',
- 'UsuarioSOAP' => 'FRGS58%',
- 'Grupo_Padre' => ''
- ];
- $cat_s = $soapClient->__soapCall($soapFunction, $soapFunctionParameters);
- // obtengo productos por categorias del webservice
- $data1 = array();
- foreach ($cat_s as $key){
- $soapClient = new SoapClient($soapURL, $soapParameters);
- $soapFunction = "Lista_Articulos";
- $soapFunctionParameters = [
- 'Usuario' => 'Gamer Store',
- 'Password' => 'Charlote5011',
- 'UsuarioSOAP' => 'FRGS58%',
- 'Filtros' => [
- 'Palabras' => '',
- 'CodigoGrupo' => $key->CodigoGrupo,
- 'CodigoMarca' => '',
- 'Solo_Modificados_desde' => '',
- 'Rango_informe' => ''
- ],
- ];
- $soapResult = $soapClient->__soapCall($soapFunction, $soapFunctionParameters);
- }
- array_push($data1,$soapResult);
- //
- $woocommerce = new Client(
- 'http://01.gamerstore.com.uy/',
- 'ck_2468a2a9dd002c173f8fb256b7ee37c752871735',
- 'cs_62b28a111193cc0709a170ec83cda5b159164344',
- [
- 'wp_api' => true,
- 'version' => 'wc/v1',
- ]
- );
- foreach($data1 as $key => $val){
- $cat= Categoria($val->CodS);
- $img= foto($val->CodS);
- $precioi = number_format($val->Costo,2);
- $pdescuento = $precioi - ($precioi* 0.20);
- $data2 = [
- 'name' => $val->Producto,
- 'type' => 'simple',
- 'sku' => $val->CodS,
- 'price' => number_format($val->Costo,2),
- //descuento del 20%
- 'regular_price' => number_format($pdescuento,2),
- 'sale_price' => number_format($pdescuento,2),
- 'description' => $val->Descripcion,
- 'short_description' => $val->Producto,
- 'categories' => [
- [
- 'id' => $cat
- ],
- [
- 'id' => 14
- ]
- ],
- 'images' => [
- [
- 'src' => 'http://test.gamerstore.com.uy/img/'.$img.'.png',
- 'position' => 0
- ]
- ]
- ];
- $woocommerce->post('products', $data2);
- }
- } catch (Exception $e) {
- echo "Exception Error: ".$e->getMessage();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement