49,99€
68 en stock
122,23€
13 en stock
122,23€
13 en stock
/* enqueue script for parent theme stylesheet */ function theme_enqueue_styles() { /*wp_enqueue_style( 'header', get_stylesheet_directory_uri() . '/header.css');*/ /*wp_enqueue_style( 'footer', get_stylesheet_directory_uri() . '/footer.css');*/ /*wp_enqueue_style( 'avada-multiples', get_stylesheet_directory_uri() . '/avada-multiples.css');*/ /*wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'avada-stylesheet' ) );*/ } /** * Traitement Icecat : On scanne les images ajoutées par WP All Import */ add_action('pmxi_gallery_image', 'traiter_image_icecat_apres_sauvegarde', 10, 3); function traiter_image_icecat_apres_sauvegarde($id_attachment, $id_produit, $image_filepath) { $logger = wc_get_logger(); $context_log = array('source' => 'debug-icecat-rca'); // Vérifie si le fichier est notre "1x1" (via son nom ou méta) $image_meta = get_post_meta($id_attachment, '_wp_attached_file', true); if (strpos($image_meta, '1x1') === false) { return; } $logger->info("--- Détection du pixel 1x1 pour Produit ID: $id_produit ---", $context_log); // 1. Identification UGS $product = wc_get_product($id_produit); $ugs = $product ? $product->get_sku() : ''; // Si pas d'UGS, on essaie de l'extraire du nom du fichier ou via une logique globale si nécessaire if (empty($ugs)) { $logger->error("UGS non trouvé pour le produit ID: $id_produit", $context_log); return; } // 2. Identification Marque (simplifiée) $titre = get_the_title($id_produit); $mots = explode(' ', trim($titre)); $marque = strtolower($mots[0]); // 3. Appel API Icecat $url = "https://data.icecat.biz/xml_s3/xml_server.cgi?prod_id=" . urlencode($ugs) . "&vendor=" . urlencode($marque) . "&lang=fr"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'); // --- DÉBUT AUTHENTIFICATION AJOUTÉE --- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, "RCA_2026:3fQd73vtTVZc5Bc"); // --- FIN AUTHENTIFICATION AJOUTÉE --- curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $xml_content = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($http_code !== 200) { $logger->error("Erreur Icecat HTTP $http_code pour $ugs", $context_log); return; } $xml = @simplexml_load_string($xml_content); $url_image_hd = (string)($xml->Product->ProductDescription['HighPic'] ?? $xml->Product['HighPic'] ?? ''); if (empty($url_image_hd)) { $logger->warning("Pas d'image HD pour $ugs", $context_log); return; } // 4. Remplacement require_once(ABSPATH . 'wp-admin/includes/media.php'); $id_nouvelle_image = media_sideload_image($url_image_hd, $id_produit, null, 'id'); if (!is_wp_error($id_nouvelle_image)) { set_post_thumbnail($id_produit, $id_nouvelle_image); wp_delete_attachment($id_attachment, true); // Supprime le 1x1 $logger->info("Succès : Image HD ajoutée pour $id_produit", $context_log); } }
49,99€
68 en stock
122,23€
13 en stock
122,23€
13 en stock
Texte SEO
Ici, inscription à la newsletter
RCA Informatique
CH. DU PRADAS – BAT. LE SAUZAC
31410 MAUZAC
05 61 75 98 95
rcai@rca-informatique.com
© Copyright – | Tous droits réservés | réalisé par Singing Dodo
© Copyright – | Tous droits réservés
réalisé par Singing Dodo
