prince67300 Posted October 14, 2014 Share Posted October 14, 2014 Hi all ! I'm trying to import some products to my prestashop using REST webservice. The problem is when I try to add a product to an empty category I created using webservice or using PS web interface, I get the following response: <error> <code><![CDATA[135]]></code> <message><![CDATA[You cannot set a position greater than the total number of products in the category, minus 1 (position numbering starts at 0).]]></message> </error> It occurs with the first product. If I add it via web interface and I add the others using webservice, it works. XML: Adding product request: <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <product> <id/> <id_manufacturer/> <id_supplier/> <id_category_default><![CDATA[1365]]></id_category_default> <new/> <cache_default_attribute/> <id_default_image/> <id_default_combination/> <id_tax_rules_group/> <position_in_category/> <type/> <id_shop_default/> <reference><![CDATA[0]]></reference> <supplier_reference/> <location/> <width/> <height/> <depth/> <weight><![CDATA[1.18]]></weight> <quantity_discount/> <ean13><![CDATA[1]]></ean13> <upc/> <cache_is_pack/> <cache_has_attachments/> <is_virtual/> <on_sale/> <online_only/> <ecotax/> <minimal_quantity/> <price><![CDATA[599]]></price> <wholesale_price/> <unity/> <unit_price_ratio/> <additional_shipping_cost/> <customizable/> <text_fields/> <uploadable_files/> <active><![CDATA[1]]></active> <redirect_type/> <id_product_redirected/> <available_for_order/> <available_date/> <condition/> <show_price/> <indexed/> <visibility/> <advanced_stock_management/> <date_add/> <date_upd/> <meta_description> <language id="1"/> </meta_description> <meta_keywords> <language id="1"/> </meta_keywords> <meta_title> <language id="1"/> </meta_title> <link_rewrite> <language id="1"/> </link_rewrite> <name> <language id="1"><![CDATA[Product]]></language> </name> <description> <language id="1"><![CDATA[<p></p>]]></language> </description> <description_short> <language id="1"><![CDATA[<p></p>]]></language> </description_short> <available_now> <language id="1"/> </available_now> <available_later> <language id="1"/> </available_later> <associations> <categories> <categories> <id/> </categories> </categories> <images> <images> <id/> </images> </images> <combinations> <combinations> <id/> </combinations> </combinations> <product_option_values> <product_option_values> <id/> </product_option_values> </product_option_values> <product_features> <product_features> <id/> <custom/> <id_feature_value/> </product_features> </product_features> <tags> <tags> <id/> </tags> </tags> <stock_availables> <stock_availables> <id/> <id_product_attribute/> </stock_availables> </stock_availables> <accessories> <products> <id/> </products> </accessories> <product_bundle> <products> <id/> <quantity/> </products> </product_bundle> </associations> </product> </prestashop> Empty category: <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <script id="tinyhippos-injected"/> <category> <id> <![CDATA[ 1365 ]]> </id> <id_parent xlink:href="http://terra.ccanim.com/api/categories/2"> <![CDATA[ 2 ]]> </id_parent> <level_depth> <![CDATA[ 2 ]]> </level_depth> <nb_products_recursive not_filterable="true"> <![CDATA[ -1 ]]> </nb_products_recursive> <active> <![CDATA[ 1 ]]> </active> <id_shop_default> <![CDATA[ 1 ]]> </id_shop_default> <is_root_category> <![CDATA[ 0 ]]> </is_root_category> <position> <![CDATA[ 2 ]]> </position> <date_add> <![CDATA[ 2014-10-07 16:29:47 ]]> </date_add> <date_upd> <![CDATA[ 2014-10-07 16:29:47 ]]> </date_upd> <name> <language id="1" xlink:href="http://terra.ccanim.com/api/languages/1"> <![CDATA[ LAN ]]> </language> </name> <link_rewrite> <language id="1" xlink:href="http://terra.ccanim.com/api/languages/1"> <![CDATA[ lan ]]> </language> </link_rewrite> <description> <language id="1" xlink:href="http://terra.ccanim.com/api/languages/1"> <![CDATA[ ]]> </language> </description> <meta_title> <language id="1" xlink:href="http://terra.ccanim.com/api/languages/1"> <![CDATA[ ]]> </language> </meta_title> <meta_description> <language id="1" xlink:href="http://terra.ccanim.com/api/languages/1"> <![CDATA[ ]]> </language> </meta_description> <meta_keywords> <language id="1" xlink:href="http://terra.ccanim.com/api/languages/1"> <![CDATA[ ]]> </language> </meta_keywords> <associations> <categories node_type="categories"/> <products node_type="products"/> </associations> </category> </prestashop> I've already read this topic http://www.prestashop.com/forums/topic/347750-solvedcant-add-product-to-empty-category-using-webservice/ but the solution is not really a solution so does anyone have an idea about this issue ? Thanks for your answers Link to comment Share on other sites More sharing options...
prince67300 Posted October 17, 2014 Author Share Posted October 17, 2014 Nobody know how to solve this issue ? Link to comment Share on other sites More sharing options...
Elizabeth_Keen Posted October 17, 2014 Share Posted October 17, 2014 See below link for getting about prestashop webservice.. http://blog.belvg.com/prestashop-web-services.html http://www.ati-erp.com ATI-ERP Link to comment Share on other sites More sharing options...
prince67300 Posted October 20, 2014 Author Share Posted October 20, 2014 (edited) I've already read this topic but the problem is not how it works. The problem is this error thrown by the server because when I try to create the product in a not-empty category, it works. Edited October 21, 2014 by prince67300 (see edit history) Link to comment Share on other sites More sharing options...
bxmatus Posted October 21, 2014 Share Posted October 21, 2014 Hello, It look like a bug in classes/Product.php at line 4872: "if ($position + 1 > count($result)) " When category is empty then only logical value for position is -1 which is not possible ... Just comment line 4872 and 4873 in that file and it will work. Matus 1 Link to comment Share on other sites More sharing options...
Sterk Posted November 6, 2019 Share Posted November 6, 2019 Hi, I am looking for a solution to import product from csv using webservice, Do you find a solution ? Thanks for any help Link to comment Share on other sites More sharing options...
camillo777 Posted November 10, 2019 Share Posted November 10, 2019 On 10/21/2014 at 5:14 PM, bxmatus said: Hello, It look like a bug in classes/Product.php at line 4872: "if ($position + 1 > count($result)) " When category is empty then only logical value for position is -1 which is not possible ... Just comment line 4872 and 4873 in that file and it will work. Matus Hello Shouldn't this be reported as a bug so that PrestaShop people could globally correct it? Link to comment Share on other sites More sharing options...
selectshop.at Posted November 10, 2019 Share Posted November 10, 2019 @camillo777 The topic on which you are posting is from 2014 ! Which Prestashop version are you using ? Webservice Api had several changes after 2014. Link to comment Share on other sites More sharing options...
camillo777 Posted November 10, 2019 Share Posted November 10, 2019 2 minutes ago, selectshop.at said: @camillo777 The topic on which you are posting is from 2014 ! Which Prestashop version are you using ? Webservice Api had several changes after 2014. Oh, I did not have the forums sorted by date, sorry. Link to comment Share on other sites More sharing options...
selectshop.at Posted November 10, 2019 Share Posted November 10, 2019 2 minutes ago, camillo777 said: Oh, I did not have the forums sorted by date, sorry. There is no possibility to sort this by date in this case. You should simply read first topic. This here is from 2014. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now