Offen Bildname = Artikelname + Artikelnummer I Ist das möglich?

akid1

Aktives Mitglied
28. Juli 2010
24
0
Hallo liebe Community!

Mein Connector wandelt die Bilder wunderbar in den Artikelnamen um, allerdings habe ich einige Artikel die leider den gleichen Namen tragen.

Wäre es möglich den Connector so zu verändern, dass er zusätzlich noch die Artikelnummer anfügt?

Gewünschtes Format:
strickmuetze-wmk103223.jpg

Ich habe mir die Datei "setArtikelBild.php" mal angeguckt, versehe aber leider nur Bahnhof/Flughafen :)

Wäre klasse wenn mir jemand helfen könnte.

Besten Dank und viele Grüße aus Köln,
Alex
 

akid1

Aktives Mitglied
28. Juli 2010
24
0
AW: Bildname = Artikelname + Artikelnummer I Ist das möglich?

Jep, ich hatte den normalen Umbau auf Artikelname irgendwann einmal gemacht...

Hier der Code:

<?php
/**
* jtlwawi_connector/dbeS/setArtikelBild.php
* Synchronisationsscript
*
* Es gelten die Nutzungs- und Lizenzhinweise unter JTL-Wawi: JTL Software
*
* @author JTL-Software <thomas@jtl-software.de>
* @copyright 2006, JTL-Software
* @link JTL-Wawi: JTL Software
* @version v1.03 / 20.08.06
*/

require_once("syncinclude.php");

$return=3;
$_POST['userID'] = $_POST['euser'];
$_POST['userPWD'] = $_POST['epass'];
if (auth())
{
$return=0;
//nur BildNr 1 wird ber¸cksichtigt
if (intval($_POST['kArtikelBild'])>0 && $_FILES['bild'])
{
//hol Anzahl unterst¸tzter Bidler
$cur_query = xtc_db_query("select configuration_value from configuration where configuration_key=\"MO_PICS\"");
$additional_pics = mysql_fetch_object($cur_query);

//hol products_id
$products_id = getFremdArtikel(intval($_POST['kArtikelBild']));
if ($products_id>0)
{
//hole einstellungen
$cur_query = eS_execute_query("select * from eazysales_einstellungen");
$einstellungen = mysql_fetch_object($cur_query);
//hole artikelnamen
$cur_query = eS_execute_query("select products_name from products_description where products_id=".$products_id." and language_id=".$einstellungen->languages_id);
$product = mysql_fetch_object($cur_query);
//ersetze sonderzeichen und alles kleinmachen
$productname = $product->products_name;
$search_array = array('‰', 'ƒ', 'ˆ', '÷', '¸', '‹', '&auml;', '&Auml;', '&ouml;', '&Ouml;', '&uuml;', '&Uuml;', '&szlig;', 'fl', 'Ë', 'È', 'Í', '‡', '‚', '·', '…', '»', ' ', '¡', '¿', '¬', '&');
$replace_array = array('ae', 'Ae', 'oe', 'Oe', 'ue', 'Ue', 'ae', 'Ae', 'oe', 'Oe', 'ue', 'Ue', 'ss', 'ss', 'e', 'e', 'e', 'a', 'a', 'a', 'E', 'E', 'E', 'A', 'A', 'A', 'und');
$productname = str_replace($search_array,$replace_array,$productname);
$productname = strtolower($productname);
$replace_param = '/[^a-zA-Z0-9]/';
$productname = preg_replace($replace_param,'-',$productname);
$productname = substr($productname, 0, 57);

// BOF - Tomcraft - 2010-08-12 - GIF/JPG/PNG enhancement - forum.jtl-software.de/xt-commerce/6908-bilder-aus- jtl-wawi-erscheinen-nicht-im- shop-2.html
$bildname=$productname."_".(intval($_POST['nNr'])-1).".";
if (intval($_POST['nNr'])==1 || $additional_pics->configuration_value>=intval($_POST['nNr'])-1)
{
$bildinfo = getimagesize ( $_FILES['bild']['tmp_name'] );
if($bildinfo[2] == "2")
{
$type = "jpg";
move_uploaded_file($_FILES['bild']['tmp_name'],DIR_FS_CATALOG_ORIGINAL_IMAGES.$bildname.$type);
chmod (DIR_FS_CATALOG_ORIGINAL_IMAGES.$bildname.$type, 0644);
$im = @imagecreatefromjpeg (DIR_FS_CATALOG_ORIGINAL_IMAGES.$bildname.$type);
}
if($bildinfo[2] == "1")
{
$type = "gif";
move_uploaded_file($_FILES['bild']['tmp_name'],DIR_FS_CATALOG_ORIGINAL_IMAGES.$bildname.$type);
chmod (DIR_FS_CATALOG_ORIGINAL_IMAGES.$bildname.$type, 0644);
$im = @imagecreatefromgif (DIR_FS_CATALOG_ORIGINAL_IMAGES.$bildname.$type);
}
if($bildinfo[2] == "3")
{
$type = "png";
move_uploaded_file($_FILES['bild']['tmp_name'],DIR_FS_CATALOG_ORIGINAL_IMAGES.$bildname.$type);
chmod (DIR_FS_CATALOG_ORIGINAL_IMAGES.$bildname.$type, 0644);
$im = @imagecreatefrompng (DIR_FS_CATALOG_ORIGINAL_IMAGES.$bildname.$type);
}

if ($im)
{
//bild skalieren
list($width, $height) = getimagesize(DIR_FS_CATALOG_ORIGINAL_IMAGES.$bildname.$type);
$ratio = $width / $height;

//thumbnail
$cur_query = xtc_db_query("select configuration_value from configuration where configuration_key=\"PRODUCT_IMAGE_THUMBNAIL_WIDTH\"");
$width_obj = mysql_fetch_object($cur_query);
$cur_query = xtc_db_query("select configuration_value from configuration where configuration_key=\"PRODUCT_IMAGE_THUMBNAIL_HEIGHT\"");
$height_obj = mysql_fetch_object($cur_query);
$new_width = 120;
if ($width_obj->configuration_value>0)
$new_width = $width_obj->configuration_value;
$new_height = round ($new_width / $ratio);
if ($new_height>$height_obj->configuration_value)
{
$new_height=$height_obj->configuration_value;
$new_width = round ($new_height * $ratio);
}
$image_p = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_p, $im, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

switch($type)
{
case "jpg":
imagejpeg($image_p, DIR_FS_CATALOG_THUMBNAIL_IMAGES.$bildname.$type);
break;

case "gif":
imagegif($image_p, DIR_FS_CATALOG_THUMBNAIL_IMAGES.$bildname.$type, 80);
break;

case "png":
imagepng($image_p, DIR_FS_CATALOG_THUMBNAIL_IMAGES.$bildname.$type);
break;
}

chmod (DIR_FS_CATALOG_THUMBNAIL_IMAGES.$bildname.$type, 0644);

//info
$cur_query = xtc_db_query("select configuration_value from configuration where configuration_key=\"PRODUCT_IMAGE_INFO_WIDTH\"");
$width_obj = mysql_fetch_object($cur_query);
$cur_query = xtc_db_query("select configuration_value from configuration where configuration_key=\"PRODUCT_IMAGE_INFO_HEIGHT\"");
$height_obj = mysql_fetch_object($cur_query);
$new_width = 200;
if ($width_obj->configuration_value>0)
$new_width = $width_obj->configuration_value;
$new_height = round ($new_width / $ratio);
if ($new_height>$height_obj->configuration_value)
{
$new_height=$height_obj->configuration_value;
$new_width = round ($new_height * $ratio);
}
$image_p = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_p, $im, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
switch($type)
{
case "jpg":
imagejpeg($image_p, DIR_FS_CATALOG_INFO_IMAGES.$bildname.$type);
break;

case "gif":
imagegif($image_p, DIR_FS_CATALOG_INFO_IMAGES.$bildname.$type, 80);
break;

case "png":
imagepng($image_p, DIR_FS_CATALOG_INFO_IMAGES.$bildname.$type);
break;
}

chmod (DIR_FS_CATALOG_INFO_IMAGES.$bildname.$type, 0644);

//popup
$cur_query = xtc_db_query("select configuration_value from configuration where configuration_key=\"PRODUCT_IMAGE_POPUP_WIDTH\"");
$width_obj = mysql_fetch_object($cur_query);
$cur_query = xtc_db_query("select configuration_value from configuration where configuration_key=\"PRODUCT_IMAGE_POPUP_HEIGHT\"");
$height_obj = mysql_fetch_object($cur_query);
$new_width = 300;
if ($width_obj->configuration_value>0)
$new_width = $width_obj->configuration_value;
$new_height = round ($new_width / $ratio);
if ($new_height>$height_obj->configuration_value)
{
$new_height=$height_obj->configuration_value;
$new_width = round ($new_height * $ratio);
}
$image_p = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_p, $im, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
switch($type)
{
case "jpg":
imagejpeg($image_p, DIR_FS_CATALOG_POPUP_IMAGES.$bildname.$type);
break;

case "gif":
imagegif($image_p, DIR_FS_CATALOG_POPUP_IMAGES.$bildname.$type, 80);
break;

case "png":
imagepng($image_p, DIR_FS_CATALOG_POPUP_IMAGES.$bildname.$type);
break;
}

chmod (DIR_FS_CATALOG_POPUP_IMAGES.$bildname.$type, 0644);
// EOF - Tomcraft - 2010-08-12 - GIF/JPG/PNG enhancement - forum.jtl-software.de/xt-commerce/6908-bilder-aus-jtl-wawi-erscheinen-nicht-im-shop-2.html

//updaten
if (intval($_POST['nNr'])==1)
eS_execute_query("update products set products_image=\"".$bildname.$type."\" where products_id=".$products_id);
else
{
//lˆsche evtl. alten Eintrag
eS_execute_query("delete from products_images where products_id=$products_id and image_nr=".(intval($_POST['nNr'])-1));
eS_execute_query("insert into products_images (products_id, image_nr, image_name) values ($products_id, ".(intval($_POST['nNr'])-1).", \"".$bildname.$type."\")");
}
}
}
}
}
}
mysql_close();
echo($return);
logge($return);

?>
 

chris99

Aktives Mitglied
3. Oktober 2007
173
0
AW: Bildname = Artikelname + Artikelnummer I Ist das möglich?

Suche:
Code:
//hole artikelnamen
$cur_query = eS_execute_query("select products_name from products_description where products_id=".$products_id." and language_id=".$einstellungen->languages_id);

Ersetze durch:
Code:
//hole artikelnamen
$cur_query = eS_execute_query("select products_name, products_model from products_description Left Join products On (products_description.products_id=products.products_id) where products_description.products_id=".$products_id." and products_description.language_id=".$einstellungen->languages_id);

Suche:
Code:
//ersetze sonderzeichen und alles kleinmachen
$productname = $product->products_name;
Ersetze durch:
Code:
//ersetze sonderzeichen und alles kleinmachen
$productname = $product->products_name . '_' . $product->products_model;

Ist aber ungetestet.
 

akid1

Aktives Mitglied
28. Juli 2010
24
0
AW: Bildname = Artikelname + Artikelnummer I Ist das möglich?

Hammer, besten Dank dafür!! Werde ich heute Abend mal einspielen.

Was muss ich den beachten damit auch die aktuellen Bilder richtig benannt werden?

Die stecken jetzt natürlich noch mit der "Artikelname.jpg" Bezeichnung auf XTCModified Server + JTL Wawi.

Danke für deine Antwort!
 

chris99

Aktives Mitglied
3. Oktober 2007
173
0
AW: Bildname = Artikelname + Artikelnummer I Ist das möglich?

Hammer, besten Dank dafür!! Werde ich heute Abend mal einspielen.

Was muss ich den beachten damit auch die aktuellen Bilder richtig benannt werden?
Du musst alle Bilder noch einmal hochschicken:
15. WEBSHOP
Dort die Häkchen für "Alle Bilder erneut versenden" und "Artikelbilder" aktivieren.

Wenn du eine lokale Testinstallation hast, solltest du die Änderung erst einmal lokal testen. Wenn nicht, dann teste erstmal mit einem Bild.

Bei Fehlern bitte mit Fehlermeldung wieder melden.
 

akid1

Aktives Mitglied
28. Juli 2010
24
0
AW: Bildname = Artikelname + Artikelnummer I Ist das möglich?

Hallo Chris,

habe es gerade mit einem Testprodukt ausprobiert, funktioniert 1A!!!

Besten Dank für deine Hilfe, echt ein hammer Forum hier :)
 

xfp

Aktives Mitglied
11. Mai 2010
92
0
AW: Bildname = Artikelname + Artikelnummer I Ist das möglich?

Hallo Zusammen,

leider funktioniert bei mir der "erneute Bilderabgleich nicht" - ich habe ca. 50.000 Bilder im Shop - der Abgleich - für neue Artikel funktioniert, die Bestellungen werden geholt aber die "ALTEN" Bilder behalten ihren alten Namen und es währe natürlich toll wenn die durch die neue Bildnamesetzung nun auch den neuen Artikelnamen bekommen. Ich habe also auf "ALLE Bilder erneut versenden" häkchen gesetzt und dann bei Artikelbilder. Hat jemand eine Idee warum er nicht alle Bilder mit dem neuen Namen rüber schiebt?

Viele Grüße XFP
 

Ähnliche Themen