Medienhirsch Posted June 9, 2017 Share Posted June 9, 2017 Hallo Ich bin gerade total verwirrt. Seit Tagen versuche ich über den Webservice Artikel anzulegen. Kategorien anlegen klappt ja schonmal. Auslesen klappt auch. Habe inzwischen ca. 20 Möglichkeiten probiert. Kann mir irgendjemand weiterhelfen? Gibt es ein Beispiel das funktioniert? Bei Erfolg auch gegen (kleines) Honorar. Danke für Eure Hilfe Link to comment Share on other sites More sharing options...
Shad86 Posted June 9, 2017 Share Posted June 9, 2017 Was genau versuchst du denn bzw. was genau geht denn nicht? Welche Presta Version nutzt du denn? Du loggst dich im Backend ein und versuchst dort einen Artikel an zu legen? Und diesen kannst du dann nciht speichern? Oder was genau passiert? Link to comment Share on other sites More sharing options...
Medienhirsch Posted June 9, 2017 Author Share Posted June 9, 2017 Hallo Ich nutze Version 1.7.1.1. Artikel im Backend anlegen ist ja kein Problem :-) Ich möchte die Artikel über den Webservice den Artikel anlegen. Hier mein Code (das letzte Beispiel) <?php /* * * Example of using the PrestShop WebService to create a product with * its stock and its image * */ define('DEBUG', true); define('_PS_DEBUG_SQL_', true); define('PS_SHOP_PATH', 'http://xxxxxxx.de/'); // Root path of your PrestaShop store define('PS_WS_AUTH_KEY', 'xxxxxxx'); // Auth key (Get it in your Back Office) require_once('PSWebServiceLibrary.php'); $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=synopsis'));$resources = $xml->children()->children();unset($resources->position_in_category);unset($resources->manufacturer_name);$resources->price = '1000';$resources->active = '1';$resources->link_rewrite = 'blabla';$resources->name = 'blabla';$resources->description = 'blabla';$resources->description_short = 'blabla';$resources->associations = '';$opt = array('resource' => 'products');$opt['postXml'] = $xml->asXML();$xml = $webService->add($opt); ?> ################################################################# Das Ergebnis (Domainname gexxt: HTTP REQUEST HEADERGET //api/products?schema=synopsis HTTP/1.1Authorization: Basic V1EzTFRGMVRIMkNBREQ4TDRMTkVMWUw1NlpJRTdBUlM6Host: xxxx.deAccept: */* HTTP RESPONSE HEADERHTTP/1.1 200 OKServer: nginxDate: Fri, 09 Jun 2017 14:56:59 GMTContent-Type: text/xml;charset=utf-8Transfer-Encoding: chunkedConnection: keep-aliveAccess-Time: 1497020219X-Powered-By: PrestaShop WebservicePSWS-Version: 1.7.1.1Execution-Time: 0.016Content-Sha1: 2d4fa4b9eb8c78441cf0ac739cb043e46cf6c186Vary: AuthorizationX-Powered-By: PleskLin RETURN HTTP BODY<?xml version="1.0" encoding="UTF-8"?><prestashop xmlns:xlink="http://www.w3.org/1999/xlink"><product> <id_manufacturer format="isUnsignedId"></id_manufacturer> <id_supplier format="isUnsignedId"></id_supplier> <id_category_default format="isUnsignedId"></id_category_default> <new></new> <cache_default_attribute></cache_default_attribute> <id_default_image notFilterable="true"></id_default_image> <id_default_combination notFilterable="true"></id_default_combination> <id_tax_rules_group format="isUnsignedId"></id_tax_rules_group> <position_in_category notFilterable="true"></position_in_category> <manufacturer_name notFilterable="true" read_only="true" readOnly="true"></manufacturer_name> <quantity notFilterable="true" read_only="true" readOnly="true"></quantity> <type notFilterable="true"></type> <id_shop_default format="isUnsignedId"></id_shop_default> <reference maxSize="32" format="isReference"></reference> <supplier_reference maxSize="32" format="isReference"></supplier_reference> <location maxSize="64" format="isReference"></location> <width format="isUnsignedFloat"></width> <height format="isUnsignedFloat"></height> <depth format="isUnsignedFloat"></depth> <weight format="isUnsignedFloat"></weight> <quantity_discount format="isBool"></quantity_discount> <ean13 maxSize="13" format="isEan13"></ean13> <isbn maxSize="13" format="isIsbn"></isbn> <upc maxSize="12" format="isUpc"></upc> <cache_is_pack format="isBool"></cache_is_pack> <cache_has_attachments format="isBool"></cache_has_attachments> <is_virtual format="isBool"></is_virtual> <state format="isUnsignedId"></state> <on_sale format="isBool"></on_sale> <online_only format="isBool"></online_only> <ecotax format="isPrice"></ecotax> <minimal_quantity format="isUnsignedInt"></minimal_quantity> <price required="true" format="isPrice"></price> <wholesale_price format="isPrice"></wholesale_price> <unity format="isString"></unity> <unit_price_ratio></unit_price_ratio> <additional_shipping_cost format="isPrice"></additional_shipping_cost> <customizable format="isUnsignedInt"></customizable> <text_fields format="isUnsignedInt"></text_fields> <uploadable_files format="isUnsignedInt"></uploadable_files> <active format="isBool"></active> <redirect_type format="isString"></redirect_type> <id_type_redirected format="isUnsignedId"></id_type_redirected> <available_for_order format="isBool"></available_for_order> <available_date format="isDateFormat"></available_date> <show_condition format="isBool"></show_condition> <condition format="isGenericName"></condition> <show_price format="isBool"></show_price> <indexed format="isBool"></indexed> <visibility format="isProductVisibility"></visibility> <advanced_stock_management format="isBool"></advanced_stock_management> <date_add format="isDate"></date_add> <date_upd format="isDate"></date_upd> <pack_stock_type format="isUnsignedInt"></pack_stock_type> <meta_description maxSize="255" format="isGenericName"><language id="1" xlink:href="http://xxxx.de/api/languages/1" format="isUnsignedId" ></language></meta_description> <meta_keywords maxSize="255" format="isGenericName"><language id="1" xlink:href="http://xxxx.de/api/languages/1" format="isUnsignedId" ></language></meta_keywords> <meta_title maxSize="128" format="isGenericName"><language id="1" xlink:href="http://xxxx.de/api/languages/1" format="isUnsignedId" ></language></meta_title> <link_rewrite maxSize="128" format="isLinkRewrite"><language id="1" xlink:href="http://xxxx.de/api/languages/1" format="isUnsignedId" ></language></link_rewrite> <name maxSize="128" format="isCatalogName"><language id="1" xlink:href="http://xxxx.de/api/languages/1" format="isUnsignedId" ></language></name> <description format="isCleanHtml"><language id="1" xlink:href="http://xxxx.de/api/languages/1" format="isUnsignedId" ></language></description> <description_short format="isCleanHtml"><language id="1" xlink:href="http://xxxx.de/api/languages/1" format="isUnsignedId" ></language></description_short> <available_now maxSize="255" format="isGenericName"><language id="1" xlink:href="http://xxxx.de/api/languages/1" format="isUnsignedId" ></language></available_now> <available_later maxSize="255" format="IsGenericName"><language id="1" xlink:href="http://xxxx.de/api/languages/1" format="isUnsignedId" ></language></available_later><associations><categories nodeType="category" api="categories"> <category> <id required="true"></id> </category></categories><images nodeType="image" api="images"> <image> <id></id> </image></images><combinations nodeType="combination" api="combinations"> <combination> <id required="true"></id> </combination></combinations><product_option_values nodeType="product_option_value" api="product_option_values"> <product_option_value> <id required="true"></id> </product_option_value></product_option_values><product_features nodeType="product_feature" api="product_features"> <product_feature> <id required="true"></id> <id_feature_value xlink:href="http://xxxxxx.de/api/product_feature_values/" required="true"></id_feature_value> </product_feature></product_features><tags nodeType="tag" api="tags"> <tag> <id required="true"></id> </tag></tags><stock_availables nodeType="stock_available" api="stock_availables"> <stock_available> <id required="true"></id> <id_product_attribute required="true"></id_product_attribute> </stock_available></stock_availables><accessories nodeType="product" api="products"> <product> <id xlink:href="http://xxxxxxx.de/api/product/" required="true"></id> </product></accessories><product_bundle nodeType="product" api="products"> <product> <id required="true"></id> <quantity></quantity> </product></product_bundle></associations></product></prestashop> HTTP REQUEST HEADERPOST //api/products HTTP/1.1Authorization: Basic V1EzTFRGMVRIMkNBREQ4TDRMTkVMWUw1NlpJRTdBUlM6Host: medienhirsch.deAccept: */*Content-Length: 3216Content-Type: application/x-www-form-urlencoded HTTP RESPONSE HEADERHTTP/1.1 400 Bad RequestServer: nginxDate: Fri, 09 Jun 2017 14:56:59 GMTContent-Type: text/xml;charset=utf-8Transfer-Encoding: chunkedConnection: keep-aliveAccess-Time: 1497020219X-Powered-By: PrestaShop WebservicePSWS-Version: 1.7.1.1Execution-Time: 0.016Set-Cookie: PrestaShop-da653d3fc831341b913f71d35c71b30c=def502006de52f546956cf2d9fb51e53982d70270a182f8a4f930b6cab1473764930c49b6105042a53f59c5fcd0a40c058ae45d7af8e930bf6b79760eee408756b9c64355e330f751064ddca5ff132e19140200589a969caf3774798f67a7feff463382d848fa1730d657dfbb7c36e7c1aafab44188cee6fd37f784df66294d585af7ae4685daa3927402b786a412eeb3346cc04d1ea8966178cb623a9723cee51938c; expires=Thu, 29-Jun-2017 14:56:59 GMT; Max-Age=1728000; path=/; domain=medienhirsch.de; httponlyVary: AuthorizationX-Powered-By: PleskLin XML SENT<?xml version="1.0" encoding="UTF-8"?><prestashop xmlns:xlink="http://www.w3.org/1999/xlink"><product> <id_manufacturer format="isUnsignedId"/> <id_supplier format="isUnsignedId"/> <id_category_default format="isUnsignedId"/> <new/> <cache_default_attribute/> <id_default_image notFilterable="true"/> <id_default_combination notFilterable="true"/> <id_tax_rules_group format="isUnsignedId"/> <quantity notFilterable="true" read_only="true" readOnly="true"/> <type notFilterable="true"/> <id_shop_default format="isUnsignedId"/> <reference maxSize="32" format="isReference"/> <supplier_reference maxSize="32" format="isReference"/> <location maxSize="64" format="isReference"/> <width format="isUnsignedFloat"/> <height format="isUnsignedFloat"/> <depth format="isUnsignedFloat"/> <weight format="isUnsignedFloat"/> <quantity_discount format="isBool"/> <ean13 maxSize="13" format="isEan13"/> <isbn maxSize="13" format="isIsbn"/> <upc maxSize="12" format="isUpc"/> <cache_is_pack format="isBool"/> <cache_has_attachments format="isBool"/> <is_virtual format="isBool"/> <state format="isUnsignedId"/> <on_sale format="isBool"/> <online_only format="isBool"/> <ecotax format="isPrice"/> <minimal_quantity format="isUnsignedInt"/> <price required="true" format="isPrice">1000</price> <wholesale_price format="isPrice"/> <unity format="isString"/> <unit_price_ratio/> <additional_shipping_cost format="isPrice"/> <customizable format="isUnsignedInt"/> <text_fields format="isUnsignedInt"/> <uploadable_files format="isUnsignedInt"/> <active format="isBool">1</active> <redirect_type format="isString"/> <id_type_redirected format="isUnsignedId"/> <available_for_order format="isBool"/> <available_date format="isDateFormat"/> <show_condition format="isBool"/> <condition format="isGenericName"/> <show_price format="isBool"/> <indexed format="isBool"/> <visibility format="isProductVisibility"/> <advanced_stock_management format="isBool"/> <date_add format="isDate"/> <date_upd format="isDate"/> <pack_stock_type format="isUnsignedInt"/> <meta_description maxSize="255" format="isGenericName"><language id="1" xlink:href="http://xxxxx.de/api/languages/1" format="isUnsignedId"/></meta_description> <meta_keywords maxSize="255" format="isGenericName"><language id="1" xlink:href="http://xxxxx.de/api/languages/1" format="isUnsignedId"/></meta_keywords> <meta_title maxSize="128" format="isGenericName"><language id="1" xlink:href="http://xxxxx.de/api/languages/1" format="isUnsignedId"/></meta_title> <link_rewrite maxSize="128" format="isLinkRewrite">blabla</link_rewrite> <name maxSize="128" format="isCatalogName">blabla</name> <description format="isCleanHtml">blabla</description> <description_short format="isCleanHtml">blabla</description_short> <available_now maxSize="255" format="isGenericName"><language id="1" xlink:href="http://xxxxxx.de/api/languages/1" format="isUnsignedId"/></available_now> <available_later maxSize="255" format="IsGenericName"><language id="1" xlink:href="http://xxxxxx.de/api/languages/1" format="isUnsignedId"/></available_later><associations></associations></product></prestashop> RETURN HTTP BODY<?xml version="1.0" encoding="UTF-8"?><prestashop xmlns:xlink="http://www.w3.org/1999/xlink"><errors><error><code><![CDATA[93]]></code><message><![CDATA[parameter "quantity" not writable. Please remove this attribute of this XML]]></message></error></errors></prestashop> Fatal error: Uncaught exception 'PrestaShopWebserviceException' with message 'This call to PrestaShop Web Services failed and returned an HTTP status of 400. That means: Bad Request.' in /var/www/web1/html/sellerfun/Presta/PSWebServiceLibrary.php:91 Stack trace: #0 /var/www/web1/html/sellerfun/Presta/PSWebServiceLibrary.php(241): PrestaShopWebservice->checkStatusCode(400) #1 /var/www/web1/html/sellerfun/Presta/Artikel_anlegen.php(36): PrestaShopWebservice->add(Array) #2 {main} thrown in /var/www/web1/html/sellerfun/Presta/PSWebServiceLibrary.php on line 91 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