A-Z Hosting Posted August 3, 2014 Share Posted August 3, 2014 I'm trying to write up a migration tool that imports from xml all the categories, products, images, attributes, etc. I've found my way around building the skeleton with no problems and it even has a tab! I'm now at the creation of Categories and Products and trying to figure out the best way to do it. I've looked at using the AdminImportController but there is no real documentation (or even coders notes) on what those functions need passed so it seems a tough route. Next I've looked at Webservice as an option. What seems to be the issue is that my calls to the webservice run and then never return to the function. If I throw the same thing in __construct() it runs fine prints a result and continues to render just fine. It's probably something simple I am overlooking. public function createCategory() { require 'PSWebServiceLibrary.php'; try { $webService = new PrestaShopWebservice('http://www.blahblah.com/ps/', '0B9UKVBxxxxxxxYFPGTLVHX8DRJG1', true); $opt['resource'] = 'customers'; $xml = $webService->get($opt); // Here we get the elements from children of customers markup "customer" $resources = $xml->customers->children(); } catch (PrestaShopWebserviceException $e) { // Here we are dealing with errors $trace = $e->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'; } echo '<table border="5">'; if (isset($resources)) { echo '<tr><th>Id</th></tr>'; foreach ($resources as $resource) { // Iterates on the found IDs echo '<tr><td>'.$resource->attributes().'</td></tr>'; } } echo '</table>'; return; } Link to comment Share on other sites More sharing options...
A-Z Hosting Posted August 4, 2014 Author Share Posted August 4, 2014 Yes I figure the attributes are going to be really tough through webservice. Is there better way to add products, categories, customers etc? I would much rather push the additions through a function or class. I was going to inject directly to the databases, but the category levels and nesting I can already tell are going to be quite a chore. Link to comment Share on other sites More sharing options...
A-Z Hosting Posted August 4, 2014 Author Share Posted August 4, 2014 I'll just go back to trying to use Category:: and Product::. Just so little documentation on what to pass them. Eventually I suppose the code itself will tell me. Link to comment Share on other sites More sharing options...
A-Z Hosting Posted August 5, 2014 Author Share Posted August 5, 2014 Yes thanks. That's what I've figured out thus far. I've got the Category.php finished, the Products.php finished. Next stop moving and assigning the Images. Any idea how that one is done? Is there a class for images? 1 Link to comment Share on other sites More sharing options...
A-Z Hosting Posted August 5, 2014 Author Share Posted August 5, 2014 classes/Image.php ? Well seems first time I looked I only saw ImagaManager and ImageType. Thanks for stating the obvious for me. 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