Jump to content

prestashop 1.5 adding products and categories via webservices


blondie63

Recommended Posts

Hi, i've a webapp (Codeigniter & PHP) to manage products catalogs (www.catalogo.mobi)

 

I'm looking Prestashop 1.5 to create public stores

 

I'd like to add products and categories from my webapp to a Prestashop store using Prestashop built-in Web Services.

 

Is it possible ?

 

Are there some sample php code like that i need ? :)

 

Thanks for help

 

Blondie

Link to comment
Share on other sites

I am not sure abotu the web services, but you can export your product tables and categories to an excel format from phpMyAdmin panel and then make it into a cvs file. You can import products and categories into prestashop with the cvs files and there you go.

 

 

Additionally, prestashop 1.5 handles phones, ipads, and the other mediums; in addition to the multi-store front options.

 

Soon I will have my prestashop service website up and I will be doing this for people who need it as I am very handy with migration of categories, products and such. If I can help in any way let me know.

Link to comment
Share on other sites

Hi blondie63,

 

I had same issue and to make it I made a module. Also you can mix webservice capacity with a module to get what you want.

 

Main problem was that product in prestashop have an integer for identification, I choosed to squat supplier reference to keep relation with my existing product on a foreign system

An other issue was importing images to this products.

The best documentation about your request is to look at AdminImport.php.

 

At the time I did not found solution to import images with webservice then for me module is still the best way.

 

Good luck :)

Link to comment
Share on other sites

Hi blondie63,

 

I had same issue and to make it I made a module. Also you can mix webservice capacity with a module to get what you want.

 

Main problem was that product in prestashop have an integer for identification, I choosed to squat supplier reference to keep relation with my existing product on a foreign system

An other issue was importing images to this products.

The best documentation about your request is to look at AdminImport.php.

 

At the time I did not found solution to import images with webservice then for me module is still the best way.

 

Good luck :)

 

There's no AdminImport.php in v1.5 !

Link to comment
Share on other sites

  • 2 months later...

Hi blondie63,

 

I had same issue and to make it I made a module. Also you can mix webservice capacity with a module to get what you want.

 

Main problem was that product in prestashop have an integer for identification, I choosed to squat supplier reference to keep relation with my existing product on a foreign system

An other issue was importing images to this products.

The best documentation about your request is to look at AdminImport.php.

 

At the time I did not found solution to import images with webservice then for me module is still the best way.

 

Good luck :)

 

i've successful tested image upload with code found here: http://doc.prestasho...mage+management

 

but i'm searching a sample code to add one product via webservice..

Link to comment
Share on other sites

  • 2 months later...

if you like, i've done a little test in php, using the webservice on PS1.5 here the code:

 

<html><head><title>CRUD Tutorial - Create example</title></head><body>
<?php
// Here we define constants /!\ You need to replace this parameters
define('DEBUG', true);
define('PS_SHOP_PATH', 'http://www.myserver.it/folder');
define('PS_WS_AUTH_KEY', 'myauthkey################');
require_once('./PSWebServiceLibrary.php');


$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$opt = array('resource' => 'products');
// $opt['id'] =8;
$xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/products?schema=blank'));
// $xml = $webService->get($opt);
$resources = $xml->children()->children();

$resources->price = '731.86';
$resources->link_rewrite = "link_rewrited_for_this_new_product";
$resources->name = "name ofthe new product";
$resources->associations->categories->category->id="11";
$resources->associations->combinations->id = "38";


unset($resources->position_in_category);
unset($resources->manufacturer_name);
unset($resources->quantity);


try
{
 $opt = array('resource' => 'products');
 $opt['postXml'] = $xml->asXML(); 
 $xml = $webService->add($opt);
 // if WebService don't throw an exception the action worked well and we don't show the following message
 echo "Successfully added.";
}
catch (PrestaShopWebserviceException $e)
{
 // Here we are dealing with errors
 echo '<b>Error : '.$e->getMessage().'</b>';
}


?>


</body></html>

 

i have unset some field because they gave me errors.

also, combinations and categories ID are known, i'm testing a way to:

insert a category, insert a product in that category, insert a bunch of combinations for that product and last make the product HAS those combinations, with different prices.

 

actually, i'm not getting on the right way, but i have to do this, so i'll find a way :D

 

hope this helps people out of here, where the ONLY documentation is that on doc.prestashop, whcih is a bit poor...

Link to comment
Share on other sites

  • 1 month later...
  • 6 months later...

i have solved this issue by adding "manually" i mean inserting things directly in the database both for categories and combinations, while the products are added via webservice... this is done primary for timeout issues, then for the complete lack of informations about those webservices and prestashop in general. i'm really disappointend about the support prestashop gives to its own users.

 

by the way, on stackoverflow .com there are many more people that gives an hand to those stuck in such programs issues.

Link to comment
Share on other sites

Thanks for your replay.

Prestashop has very bad documentation about webservice (generally i would say it sux) so everybody has the same problem all the time. I'll try to do this via webservice but i think i'll need to forgive this and do this manually like you do. 

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...