ArashAnvari Posted December 5, 2016 Share Posted December 5, 2016 (edited) For Prestashop 1.6.1.7 Hello, I have a section in my site visitors they can express their product (second-hand) with features such as multiple photos, product name, product price, contact the seller, description, keywords (optional) them. I'm going through prestashop webservice after the form is submitted and record on second-hand product categories, Categories ID is 994. I wrote this code: <?php $shop_url = 'http://subdomain.test.com'; $secret_key = '9CQEDRKAD5IF8C9FFPP59T7AJSCPIW2Q'; $debug = true; require_once('./PSWebServiceLibrary.php'); try { $webService = new PrestaShopWebservice($shop_url, $secret_key, $debug); $xml = $webService->get(array('url' => $shop_url.'/api/products?schema=blank')); $resources = $xml->children()->children(); if (!isset($_POST['btn_submit'])) { $html = '<form action="" method="POST"><table border=1>'; foreach ($resources as $key => $resource) { $html .= '<tr><th>'.$key.'</th><td>'; $html .= '<input type="text" name="form['.$key.']" value=""/>'; $html .= '</td></tr>'; } $html .= '<td colspan=2><input type="submit" name="btn_submit" value="btn_submit" /></td>'; $html .= '</table></form>'; echo $html; } else { foreach ($resources as $nodeKey => $node) { $resources->$nodeKey = $_POST['form'][$nodeKey]; } try { $opt = array('resource' => 'products'); $opt['postXml'] = $xml->asXML(); $xml = $webService->add($opt); echo "Successfully added."; } catch(PrestaShopWebserviceException $ex) { echo 'Other error: <br />' . $ex->getMessage(); } } } catch (PrestaShopWebserviceException $ex) { echo 'Other error: <br />' . $ex->getMessage(); } ?> this is add_product.php in prestashop root folder. PSWebServiceLibrary.php in prestashop root folder. Why not working properly, and how can I sum up the form that the product name, product description, product price. result screentshot attached. Edited December 5, 2016 by reminoco (see edit history) Link to comment Share on other sites More sharing options...
ArashAnvari Posted December 6, 2016 Author Share Posted December 6, 2016 Help me please Link to comment Share on other sites More sharing options...
Seamoose IT Solution Posted January 17, 2017 Share Posted January 17, 2017 I believe the question is "what are the required elements/parameterns to provide in the create product webservice XML". Am looking for the same answer. anyone who can help here? 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