Jump to content

affichage name categories web service


xEL

Recommended Posts

Bonjour,

 

je suis nouveau sur prestashop , je travail avec le service web, pour la gestions des ressources

 

mon probleme est avec la ressource categories j'arrive pas afficher le name des categories

j'essai avec cette fonction mais elle me retourne la liste vide sans erreur

function affichername($table)
 {
 try
 {
  $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
  $opt['resource'] = $table;
  $xml = $webService->get($opt);
  $resources = $xml->children()->children();
  $i = 0;
  $data = null;
  if (isset($resources))
{
if (!isset($_GET['id']))
{
 foreach ($resources as $resource)
 {
  $id = $resource->attributes();
  $opt2['resource'] = $table;
  $opt2['id'] = $id;
  $xml2 = $webService->get($opt2);
  $manufacturers = $xml2->children()->children();

  foreach($manufacturers as $key => $value)
  {

   if($key == 'id' || $key == 'name'){
	 if($key == 'id') $data[$i][0] = $value;
	 if($key == 'name') $data[$i][1] = $value;
   }
  }
  $i++;
 }
  $j = 0;
  echo '<select name='.$table.'>';
  for($j == 0; $j < $i; $j++)
  {
   echo '<option value="'.$data[$j][0].'">'.$data[$j][1].'</option>';
  }
  echo "</select>";
}
[spam-filter]
 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';
 }
 }

 

A l'appel du fonction je met affichername('categories')

Merci

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...