Jump to content

Create product with image by webservice


Recommended Posts



I'm trying to create a product by webservice (after a long time I finally succeeded), but I don't understand how to add an image to my product while creating it.

      $xml = $webService->get(array('resource' => 'products?schema=synopsis'));
     $resources = $xml->children()->children();

     // Champs requis
     $resources->quantity = $product->getQuantity();
     $resources->price = '15.5';
     $resources->out_of_stock = '0';
     $resources->name->language[1] = $product->getName();
     $resources->link_rewrite->language[1] = $product->getEan();

     // Meta
     $resources->meta_keywords->language[1] = $product->getMetaKeywords();
     $resources->meta_title->language[1] = $product->getMetaTitle();
     $resources->meta_description->language[1] = $product->getMetaDescription(); /// vide
     // References
     $resources->ean13 = $product->getEan();
     $resources->supplier_reference = $product->getEan();

     // Inventaire
     $resources->active = '1';
     $resources->available_for_order = '1';
     $resources->condition = 'new';
     $resources->show_price = '1';


     // associer a une categorie
     $resources->associations->categories->addChild('category')->addChild('id', 2);
     $xml = $webService->add(
                         'resource' => 'products',
                         'postXml' => $xml->asXML()


Also, I want to add a description to my product but when I do :

$resources->description->language[1] = 'foo';

it works, but when I have :

$resources->description->language[1] = '<strong>foo</strong>';

I have an error with code 500.

I tried with cdata and/or htmlentities, but I can't make it work.


Please help ^^' Thanks :)


P.S. : I'm on 1.4.3

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...