bokasmoka Posted March 2, 2018 Share Posted March 2, 2018 Hello! This is my current situation: I started using PS API (webService), but I have a problem. I want to update(edit) products name. I'm not sure how do I do that.. At this moment I'm only able to display all of the attributes that a node contains. I want to be able to take whatever attributes i need. Here is the code (part of it) that I think I need to modify: if (isset($_GET['id']) && isset($_POST['id'])) // Here we check id cause in every resource there's an id { // Here we have XML before update, lets update XML with new values foreach ($resources as $nodeKey => $node) $resources->$nodeKey = $_POST[$nodeKey]; } // And call the web service try { $opt = array('resource' => 'products'); $opt['putXml'] = $xml->asXML();; $opt['id'] = $_GET['id']; $xml = $webService->edit($opt); // if WebService don't throw an exception the action worked well and we don't show the following message echo "Successfully updated."; } catch (PrestaShopWebserviceException $ex) { // Here we are dealing with errors $trace = $ex->getTrace(); if ($trace[0]['args'][0] == 404) echo 'Bad ID'; else if ($trace[0]['args'][0] == 401) echo 'Bad auth key'; else echo 'Other error<br />'.$ex->getMessage(); } Please check the image that i attached to see the error that I get. So I guess my question is: How to exclude an attribute from this XML? Thanks! 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