Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/02/2015, 09:01
oskar5
 
Fecha de Ingreso: abril-2008
Mensajes: 141
Antigüedad: 16 años, 1 mes
Puntos: 1
magento error guardar productos

que pena muevo aca el post a ver si aqui alguien puede ayudarme

hola a todos no he podido con esto porfavor si alguien puede le agradezco.

mi codigo es para en primer lugar abstraer datos de un servicio web, luego recorro esos datos, despues los almaeno en variables y por ultimo, los deseo guardar en MAGENTO con el servicio web del mismo

hasta aqui ambas cosas me funcionaban por separado al querer unirlas no logro hacerlo ayuda porfavor

Código PHP:
Código:
<?php
//ejemplo de consulta al servicio web ALICE por inventario
$xml = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<request>
<type>Product</type>
<filters>
<filter>
<field>classid</field>
<like>class_899m</like>
</filter>
<filter>
<field>currency</field>
<like>cop</like>
</filter>
</filters>
</request>
EOD;
                        
$url = "http://xxxxxxxxxxx/get.php";
$data = array('request'=>$xml);
$options = array
    (
    'http' => array
        (
            'header'=>"Content-type: application/x-www-form-urlencoded\r\n",
            'method'=>'POST',
            'content'=>http_build_query($data)
        ),
    );
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$xmlresp=simplexml_load_string($result) or die ("message");
                
//recorrer el xmlresp

foreach($xmlresp->products->product as $item)
    {
        $whenmod= $item->whenmod;
        $sku= $item->sku;
        $name= $item->name;
        $release= $item->release;
        $released= $item->released;
        $enable= $item->enable;
        $online= $item->online;
        $sellnew= $item->sellnew;
        $sellused= $item->sellused;
        $platform= $item->platform;
        $category= $item->category;
        $categoryid= $item->categoryid;
        $box= $item->box;
        $publisher= $item->publisher;
        $genre= $item->genre;
        $upc= $item->upc;
        

    //pasar informacion a MAGENTO
    $client = new SoapClient('http:/xxxxxxxxxxxxxxxxxx/index.php/api/soap/?wsdl');

    // datos de conexion con el servicio web de magento
    $session = $client->login('playoscar', 'playtrade55');

    // get attribute set
    $attributeSets = $client->call($session, 'product_attribute_set.list');
    $attributeSet = current($attributeSets);

    $result = $client->call($session, 'catalog_product.create', array('simple', $attributeSet['set_id'], 'product_sku', array(
        'categories' => array(2),
        'websites' => array(1),
        'name' => "$name",
        'description' => 'descripcion del videojuego',
        'short_description' => 'pequeña descripcion del producto',
        'status' => $online,
        'visibility' => '4',
        'special_from_date' => "$release",
        'special_to_date' => "$released",        
        'price' => "$sellnew",
        'tax_class_id' => '1',
        'meta_title' => 'Product meta title',
        'meta_keyword' => "$name",
        'meta_description' => "$name",
        'category_ids ' => '16',
        'sku' => "$sku",
        'custom_design' => 'ma_petsyshop',
        'custom_layout_update' => '1 column',
        'options_container ' => 'Block after Info Column',
        'qty' => '2',
        'manage_stock ' => 'yes',
        'use_config_min_qty' => '1'
    )));

    
}

?>