Jump to content

webservice add product but cannot find it to the front end


Recommended Posts

I just started to do some tests on webservices and I found this issue.

I successfully added a product throught webservice and all is ok in the backend.

The issue is that I cannot find it in the front end.

 

I used the PSWebServiceLibrary.php from tutorial.

Prestashop version 1.5.2.

 

I will appreciate any suggest.

Thanks in advance.

 

Follow the script I used for this easy test.

 

 

try

{

$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);

$opt = array('resource' => 'products');

 

$xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/products?schema=blank'));

 

$resources = $xml->children()->children();

 

unset($resources->position_in_category);

unset($resources->manufacturer_name);

 

unset($resources->supplier);

unset($resources->supplier_reference);

unset($resources->location);

unset($resources->ean13);

unset($resources->upc);

//unset($resources->$wholesale_price);

//unset($resources->ecotax);

 

unset($resources->quantity);

unset($resources->associations->categories->category);

 

$resources->price = '2000.00';

$resources->active = '1';

$resources->id_category_default = '3';

$resources->minimal_quantity = '1';

$resources->available_for_order = '1';

$resources->show_price = '1';

$resources->out_of_stock = '0';

$resources->condition = 'new';

 

//$resources->quantity = '50';

$resources->link_rewrite = 'blabla';

$resources->name = 'blabla-test';

$resources->description = 'blabla-descr';

$resources->description_short = 'blabla-descr-short';

 

$resources->associations->categories->addChild('category')->addChild('id', 2);

 

$opt = array('resource' => 'products');

$opt['postXml'] = $xml->asXML();

$xml = $webService->add($opt);

}

catch (PrestaShopWebserviceException $ex)

{

// Here we are dealing with errors

$trace = $ex->getTrace();

if ($trace[0]['args'][0] == 404) echo 'Bad ID';

else if ($trace[0]['args'][0] == 401) echo 'Bad auth key';

else echo 'Other error<br />'.$ex->getMessage().'<br><br>';

}

Link to comment
Share on other sites

Hi kalmmo I have the same problem, I found that for each product saved with api a row into table ps_product_attribute are created, deleting this one the product begin to show into front end. If you create instead the product from backend the row in that table are not created..

Link to comment
Share on other sites

×
×
  • Create New...