Jump to content

Webservice - theme from scratch


Katia Smet

Recommended Posts

Hi everyone

 

I'm new in Prestashop and it seemed good to build a webshop for a client in it. I have experience with php, html, css, js, ... I designed the webshop and I have the static webpages.

 

Now I tried to build this with prestashop but it just seems so complex to create a proper structure for each page? Is it correct that you can only control the structure from the back office with modules ? Can I make this easier?

 

As an alternative I tried to do api calls with json but posting information f.e. a customer won't work. I'm trying to do the post with slim so I can build my app with react. But I keep getting errors on the asXML line

 

$app->get($base, function($request, $response, $args){
 
  try
  {
  $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
 
    $xml->customer->firstname = 'a';
    $xml->customer->lastname = 'a';
    $xml->customer->email = '[email protected]';
    $xml->customer->newsletter = '1';
    $xml->customer->optin = '1';
    $xml->customer->active = '1';
 
    $opt = array('resource' => 'customers');
    $opt['postXml'] = $xml->asXML();
    $xml = $webService->add($opt);
  }
  catch (PrestaShopWebserviceException $e)
  {
  $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';
  }
 
  $test = 'ok';
 
  $response->getBody()->write($test);
  return $response->withHeader('Content-Type','application/json');
 
});
 
Can somebody help me please? I've done so much research...
Thx
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...