Jump to content

insertion d'images


Recommended Posts

Bonjour,

L'import de mes produits (4000) d'un PS 1.4.6 vers PS 1.5.2 avec un fichier csv m'a donné un résultat incomplet et irrégulier, pour certains produits la création de ou des images ne c'est pas faite, pour d'autres le stock n'a pas été récupéré.Enfi un joli foutoir.

Je souhaiterai avoir un exemple ou un tuto qui explique comment creer une image pour un produit sélectionné par son id ou sa ref (nom des classes et utilisation). Cela me permettra de faire une moulinette pour intégrer au moins les images.

Merci d'avance et bonne journée a tous

 

Alain

Link to comment
Share on other sites

Juste une info brève en lisant ton topic en passant.

trvaillant sur une iterface d'admin de la boutique a part, j'ai du gérer ce problème d'image.

J'utilise principalement le webservice.

Et entre autre CURL pour les images.

Un exemple d'une partie de mon code.

// insertion image par defaut
  $img=$_SERVER["DOCUMENT_ROOT"].'/photos/prod/large/'.$image_defaut;
  $data = array('image'=>"@".$img.";type=image/jpeg");
  // envoie de l'image via CURL
  $curl = curl_init();
  curl_setopt($curl,CURLOPT_HEADER, 1);
  curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl,CURLINFO_HEADER_OUT, 1);
  curl_setopt($curl, CURLOPT_URL, 'http://test143.xxxxx.info/api/images/products/'.$id_produit.'/');
  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
  curl_setopt($curl, CURLOPT_POST, 1);
  curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Expect:' ));
  curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  curl_setopt($curl, CURLOPT_HTTPAUTH, 'CURLAUTH_BASIC');
  curl_setopt($curl, CURLOPT_USERPWD, 'ton identifiant webservice:');
  $response=curl_exec($curl);
  $index = strpos($response, "\r\n\r\n");
  $header = substr($response, 0, $index);
  $body = substr($response, $index + 4);
  $headerArrayTmp = explode("\n", $header);
  $headerArray = array();
  foreach ($headerArrayTmp as &$headerItem)
  {
   $tmp = explode(':', $headerItem);
   $tmp = array_map('trim', $tmp);
   if (count($tmp) == 2)
 $headerArray[$tmp[0]] = $tmp[1];
  }
  if (curl_getinfo($curl, CURLINFO_HTTP_CODE)==200)
  {
   echo '<p class="confirm">Image ajoutée avec succès : '.$image_defaut.'</p>';
  }
  else
  {
   $err++;
   $erreure.= 'Erreure ajout image : '.$image_defaut.' <br>
  Erreure CURL : '.curl_error($curl).'<br>
  Code retour HTTP : '.curl_getinfo($curl, CURLINFO_HTTP_CODE).'<br>
  retour header : '.print_r($headerArray);
  }
  curl_close($curl);

Link to comment
Share on other sites

  • 2 months later...

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