Jump to content

WebService not constant working


Orien

Recommended Posts

Hello,

 

I created a service to update stock and add new products to my prestashop store. I update around 1000 + products and it takes me about 4500 seconds to do the service (i do it at 4:00 am when there is no traffic).

 

Its writen in PHP. The problem is:

 

Sometimes it runs ok till the end, and since last month it is giving me a error after 30 minutes

 

Fatal error: Uncaught exception 'PrestaShopWebserviceException' with message 'This call to PrestaShop Web Services failed and returned an HTTP status of 500. That means: Internal Server Error.' in C:\Users\Admin\Desktop\site\aon\prestashop\api\PSWebServiceLibrary.php:92 Stack trace: #0 C:\Users\Admin\Desktop\site\aon\prestashop\api\PSWebServiceLibrary.php(229): PrestaShopWebservice->checkStatusCode(500) #1 C:\Users\Admin\Desktop\site\aon\prestashop\application\controllers\api.php(289): PrestaShopWebservice->add(Array) #2 C:\Users\Admin\Desktop\site\aon\prestashop\application\controllers\api.php(46): Api->createProducts() #3 [internal function]: Api->index('8ecdd3f4b306bc3...') #4 C:\Users\Admin\Desktop\site\aon\prestashop\system\core\CodeIgniter.php(359): call_user_func_array(Array, Array) #5 C:\Users\Admin\Desktop\site\aon\prestashop\index.php(202): require_once('C:\Users\Admin\...') #6 {main} thrown in C:\Users\Admin\Desktop\site\aon\prestashop\api\PSWebServiceLibrary.php on line 92

 

The fun part is that the error is never in the same product (i print the product before it adds to prestashop) and there is no error on the database either.

 

Anyone experienced this error ? Maybe something on the server ?
 

Link to comment
Share on other sites

are you sending in an array of products or are you adding a product 1 by 1. 

 

If you are sending an array of products, how many are you sending at a time?

 

I'm adding them 1 by 1 ... Is there a possibility to add them all together ?

 

I did a debug now and it gives me this error 

<error>
<code><![CDATA[97]]></code>
<message><![CDATA[[SQL Error] Duplicate entry '0-1602' for key 'PRIMARY'. From ProductCore->setWsCategories() Query was : 
					INSERT INTO `ps_category_product` (`id_category`, `id_product`, `position`)
					VALUES (0, 1602, 0),(0, 1602, 1)]]></message>
</error>
<error>
<code><![CDATA[85]]></code>
<message><![CDATA[Error occurred while setting the categories value]]></message>
</error>

The thing is before this one that product was updated correctly and didnt gave me the error... 

Link to comment
Share on other sites

  • 1 year later...

Hi, 

 

I'm getting a similar error when doing a POST request to add a new product. Which with my limited knowledge looks like an issue in Prestashop backend somehow but I also know others have managed to make a POST request and made it work. Any help is much appreciated:
 

<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<errors>
<error>
<code><![CDATA[97]]></code>
<message><![CDATA[
 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3. From ProductAdd->hookactionProductSave() Query was : 
SELECT *
FROM ps_product_lang
WHERE id_product=]]></message>
</error>
<error>
<code><![CDATA[97]]></code>
<message><![CDATA[[sql Error] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 1' at line 3. From ProductAdd->hookactionProductSave() Query was : 
SELECT *
FROM ps_stock_available
WHERE id_product= limit 1]]></message>
</error>
<error>
<code><![CDATA[97]]></code>
<message><![CDATA[[sql Error] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 1' at line 3. From ProductAdd->hookactionProductSave() Query was : 
SELECT *
FROM ps_product
WHERE id_product= limit 1]]></message>
</error>
<error>
<code><![CDATA[97]]></code>
<message><![CDATA[[sql Error] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 1' at line 3. From ProductAdd->hookactionProductSave() Query was : 
SELECT *
FROM ps_product_carrier
WHERE id_product= limit 1]]></message>
</error>
<error>
<code><![CDATA[97]]></code>
<message><![CDATA[[sql Error] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3. From ProductAdd->hookactionProductSave() Query was : 
SELECT *
FROM ps_image
WHERE id_product=]]></message>
</error>
</errors>
</prestashop>
Link to comment
Share on other sites

  • 2 weeks later...

You have to clear the product associations categories list, before updating the item.

 

product.associations.categories.Clear();

 

//give new association that you want, could be the same

Bukimedia.PrestaSharp.Entities.AuxEntities.category associationCategory = new Bukimedia.PrestaSharp.Entities.AuxEntities.category(CategoryIDThatYouWant);
product.associations.categories.Add(associationCategory);

 

productfactory.Update(product);

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