paplo22 Posted September 28, 2016 Share Posted September 28, 2016 (edited) Witam Walczę z dodaniem produktu do presty poprzez API, ale już nie mam pomysłu przeczytałem rożne fora zagranice/polskie, kopiowałem przykłady, tworzyłem własne i nic cały czas ten sam błąd: Uncaught exception 'PrestaShopWebserviceException' with message 'Bad parameters given' in PSWebServiceLibrary.php:238 Stack trace: #0 Proszę o jakąs pomoc czego mi brakuje: try { $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); // Starting webservice $xml = $webService->get(array('resource' => 'products?schema=blank')); // Getting product schema } catch(PrestashopWebserviceException $ex){ echo $ex->getMessage(); return -1; } $resources = $xml->children()->children(); unset($resources->position_in_category); unset($resources->manufacturer_name); unset($resources->id_default_combination); unset($resources->quantity); $resources->id_category_default = '2'; $resources->id_shop_default = '1'; $resources->id_tax_rules_group = '1'; $resources->minimal_quantity = '1'; $resources->supplier_reference = 'PP22222'; $resources->active = '0'; $resources->available_for_order = '1'; $resources->show_price = '1'; $resources->id_tax_rules_group = '1'; //$ProductName = 'Sukienka ladna'; //$link = $ProductName; //$link = preg_replace('/[^a-zA-Z0-9]/', '-', $link); $resources->link_rewrite->language[0][0] = 'Sukienka-ladna'; //$link; $resources->name->language[0][0] = 'Sukienka UNIWERSAL'; //$ProductName; $resources->description->language[0][0] = '...'; //$resources->associations->categories->category->id = '2'; $opt['postXml'] = $xml->asXML(); $response = $webService->add($opt); najnowsze inspiracje:https://www.prestashop.com/forums/topic/532659-webservice-add-product-along-with-the-attributes-and-combinations/ The main problem is that you assume the webservice API allows you to insert or update using associations. Except for a few badly documented cases it doesn't. So you need to split your post calls. First write products (using associations here to assign categories is supported) Then write combinations (using associations here to assign product option values is supported) Then write stock_availables and any other things you need that refer back to products and combinations za bardzo nie rozumie co ma na myśli "using associations here to assign categories is supported" Edited September 28, 2016 by paplo22 (see edit history) Link to comment Share on other sites More sharing options...
paplo22 Posted September 30, 2016 Author Share Posted September 30, 2016 Już ze wszystkimi problemami sobie poradziłem, dodawanie produktu kombinacji i ilości. [temat zamknięty] Link to comment Share on other sites More sharing options...
odkojota Posted November 13, 2016 Share Posted November 13, 2016 Spoko, mógłbyś odpisać z czym miałeś problem i jak to rozwiązałeś. 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