USERFELD an osCommerce übergeben

Antworten

USERFELD an osCommerce übergeben

angelegtes DB-Feld in der Tabelle "products" --> products_userfield_7 (varchar 255)

im logger (cao) wird das products_userfield[7] korrekt übergeben...

leider bleibt das DB-Feld jedoch leer.

Mein verwendetes / geändertes Skript:

Code: Alles auswählen

<?php

//--------------------------------------------------------------

... (einiges entfernt) ...

function ProductsUpdate ()
{
  global $_POST, $LangID;

  $products_id = tep_db_prepare_input($_POST['pID']);
  
  // product laden
  $SQL = "select products_quantity,products_model,products_ean,products_image,products_price,products_date_available,products_weight,products_status,products_tax_class_id, manufacturers_id, manufacturers_model";

  if (DREI_PRODUKTBILDER == true)
  {
    $SQL .= ", products_image_medium, products_image_large ";
  }
  $count_query = tep_db_query($SQL . " from " . TABLE_PRODUCTS . " where products_id='" . $products_id . "'");
  if ($product = tep_db_fetch_array($count_query))
  {
    $exists = 1;
    // aktuelle Produktdaten laden
    $products_quantity = $product['products_quantity'];
    $products_model = $product['products_model'];
    $products_ean = $product['products_ean'];
	$products_userfield_7 = $product['products_userfield'][7];
	$products_image = $product['products_image'];
           
    if (DREI_PRODUKTBILDER == true)
    {
      $products_image_med = $product['products_image_medium'];
      $products_image_large = $product['products_image_large'];
    }
           
    $products_price = $product['products_price'];
    $products_date_available = $product['products_date_available'];
    $products_weight = $product['products_weight'];
    $products_status = $product['products_status'];
    $products_tax_class_id = $product['products_tax_class_id'];
    $manufacturers_id = $product['manufacturers_id'];
    $manufacturers_model = $product['manufacturers_model'];
  } 
  else $exists = 0; 
        
  // Variablen nur ueberschreiben wenn als Parameter vorhanden !!!
  if (isset($_POST['products_quantity'])) $products_quantity = tep_db_prepare_input($_POST['products_quantity']);
  if (isset($_POST['products_model'])) $products_model = tep_db_prepare_input($_POST['products_model']);
  if (isset($_POST['products_ean'])) $products_ean = tep_db_prepare_input($_POST['products_ean']);
  if (isset($_POST['products_userfield'][7])) $products_userfield_7 = tep_db_prepare_input($_POST['products_userfield'][7]);

  if (isset($_POST['products_image'])) $products_image = tep_db_prepare_input($_POST['products_image']);
        
  if (DREI_PRODUKTBILDER == true)
  {
    if (isset($_POST['products_image_med'])) $products_image_med = tep_db_prepare_input($_POST['products_image_med']);
    if (isset($_POST['products_image_large'])) $products_image_large = tep_db_prepare_input($_POST['products_image_large']);
  }
        
  if (isset($_POST['products_price'])) $products_price = tep_db_prepare_input($_POST['products_price']);
  if (isset($_POST['products_date_available'])) $products_date_available = tep_db_prepare_input($_POST['products_date_available']);
  if (isset($_POST['products_weight'])) $products_weight = tep_db_prepare_input($_POST['products_weight']);
  if (isset($_POST['products_status'])) $products_status = tep_db_prepare_input($_POST['products_status']);
  if (isset($_POST['products_tax_class_id'])) $products_tax_class_id = tep_db_prepare_input($_POST['products_tax_class_id']);
  if (isset($_POST['manufacturers_id'])) $manufacturers_id = tep_db_prepare_input($_POST['manufacturers_id']);
  if (isset($_POST['manufacturers_model'])) $manufacturers_model = tep_db_prepare_input($_POST['manufacturers_model']);

  if (file_exists('cao_produpd_1.php')) { include('cao_produpd_1.php'); }
        
  $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';
          
  if (DREI_PRODUKTBILDER == true)
  {
    $sql_data_array = array('products_id' => $products_id,
                            'products_quantity' => $products_quantity,
                            'products_model' => $products_model,
                            'products_ean' => $products_ean,
							'products_userfield_7' => $products_userfield_7,
							'products_image' => ($products_image == 'none') ? '' : $products_image,
                            'products_image_medium' => ($products_image_med == 'none') ? '' : $products_image_med,
                            'products_image_large' => ($products_image_large == 'none') ? '' : $products_image_large,
                            'products_price' => $products_price,
                            'products_date_available' => $products_date_available,
                            'products_weight' => $products_weight,
                            'products_status' => $products_status,
                            'products_tax_class_id' => $products_tax_class_id,
                            'manufacturers_id' => $manufacturers_id,
                            'manufacturers_model' => $manufacturers_model);
  }
    else
  {
    $sql_data_array = array('products_id' => $products_id,
                            'products_quantity' => $products_quantity,
                            'products_model' => $products_model,
							'products_ean' => $products_ean,
							'products_userfield_7' => $products_userfield[7],
                            'products_image' => ($products_image == 'none') ? '' : $products_image,
                            'products_price' => $products_price,
                            'products_date_available' => $products_date_available,
                            'products_weight' => $products_weight,
                            'products_status' => $products_status,
                            'products_tax_class_id' => $products_tax_class_id,
                            'manufacturers_id' => $manufacturers_id,
                            'manufacturers_model' => $manufacturers_model);
  }
          
  if ($exists==0) // Neuanlage (ID wird an CAO zurueckgegeben !!!)
  {
    $mode='APPEND';
    $insert_sql_data = array('products_date_added' => 'now()');
    $sql_data_array = /*tep_*/array_merge($sql_data_array, $insert_sql_data);
    tep_db_perform(TABLE_PRODUCTS, $sql_data_array);
    $products_id = tep_db_insert_id();
  } 
  elseif ($exists==1) //Update
  {
    $mode='UPDATE';
    $update_sql_data = array('products_last_modified' => 'now()');
    $sql_data_array = /*tep_*/array_merge($sql_data_array, $update_sql_data);
      
    tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', 'products_id = \'' . tep_db_input($products_id) . '\'');
  }
        
  $languages = tep_get_languages();
  for ($i = 0, $n = sizeof($languages); $i < $n; $i++) 
  {
    $language_id = $languages[$i]['id'];
          
    // Bestehende Daten laden
    $SQL = "select products_id,products_name,products_description,products_url,products_viewed,language_id";
	  
    if (HEADERTAGS == true)
    {
      $SQL .= ", products_head_title_tag, products_head_desc_tag, products_head_keywords_tag";
    }
	
    $desc_query = tep_db_query($SQL . " from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id='" . $products_id . "' and language_id='" . $language_id . "'");
    if ($desc = tep_db_fetch_array($desc_query))
    {
      $products_name = $desc['products_name'];
      $products_description = $desc['products_description'];
      $products_url = $desc['products_url'];
	    
      if (HEADERTAGS == true)
      {
        $products_head_title_tag    = $desc['products_head_title_tag'];
        $products_head_desc_tag     = $desc['products_head_desc_tag'];
        $products_head_keywords_tag = $desc['products_head_keywords_tag'];	      
      }
    }
          
    // uebergebene Daten einsetzen
    if (isset($_POST['products_name'][$LangID]))              $products_name             =tep_db_prepare_input($_POST['products_name'][$LangID]);
    if (isset($_POST['products_description'][$LangID]))       $products_description      =tep_db_prepare_input($_POST['products_description'][$LangID]);
    if (isset($_POST['products_url'][$LangID]))               $products_url              =tep_db_prepare_input($_POST['products_url'][$LangID]);
	  
    if (isset($_POST['products_meta_title'][$LangID]))        $products_head_title_tag   =tep_db_prepare_input($_POST['products_meta_title'][$LangID]);	  
    if (isset($_POST['products_meta_description'][$LangID]))  $products_head_desc_tag    =tep_db_prepare_input($_POST['products_meta_description'][$LangID]);
    if (isset($_POST['products_meta_keywords'][$LangID]))     $products_head_keywords_tag=tep_db_prepare_input($_POST['products_meta_keywords'][$LangID]);    

    $sql_data_array = array('products_name' => $products_name,
                            'products_description' => $products_description,
                            'products_url' => $products_url);
          
    if (HEADERTAGS == true)
    {
      $sql_data_array2 = array('products_head_title_tag'    => $products_head_title_tag,
                               'products_head_desc_tag'     => $products_head_desc_tag,
                               'products_head_keywords_tag' => $products_head_keywords_tag);
      
      $sql_data_array = /*tep_*/array_merge($sql_data_array, $sql_data_array2); 
    }
          
    if ($exists==0) // Insert
    {
      $insert_sql_data = array('products_id' => $products_id,
                               'language_id' => $language_id);
      $sql_data_array = /*tep_*/array_merge($sql_data_array, $insert_sql_data);
      tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
    } 
    elseif (($exists==1)and($LangID==$language_id)) // Update
    {
      tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', 'products_id = \'' . tep_db_input($products_id) . '\' and language_id = \'' . $language_id . '\'');
    }
  }
  if (file_exists('cao_produpd_2.php')) { include('cao_produpd_2.php'); }
  
  print_xml_status (0, $_POST['action'], 'OK', $mode, 'PRODUCTS_ID', $products_id);
}

//--------------------------------------------------------------
 
... (einiges entfernt)...

?>

Re: USERFELD an osCommerce übergeben

Hallo,

ich denke da sind einige Fehler drin. Schaumal folgendes an:

Code: Alles auswählen

  if ($product = tep_db_fetch_array($count_query))
{
  $exists = 1;
  // aktuelle Produktdaten laden
  $products_quantity = $product['products_quantity'];
  $products_model = $product['products_model'];
  $products_ean = $product['products_ean'];
  $products_userfield_7 = $product['products_userfield'][7];
  // müsste $products_userfield_7 = $product['products_userfield_7']; lauten,
...
$products_userfield_7 = $product['products_userfield'][7];
müsste $products_userfield_7 = $product['products_userfield_7']; lauten,
im $SQL = "select products_quantity,.... fehlt das Feld products_userfield_7

Code: Alles auswählen

$sql_data_array = array('....'products_userfield_7' => $products_userfield[7],...
Das sollte 'products_userfield_7' => $products_userfield_7,... lauten.

Userfelder werden im übrigen nur mit der K-Version übertragen. Schalt mal den Logger im Script an, falls er eingebaut ist, und schau ob das Feld products_userfield[7] im Shop ankommt.
bis dahin
Thoren
______________________________________________
Alles wird gut....:)
______________________________________________
Shopsysteme
Oxid CE mit COI-Modul

Re: USERFELD an osCommerce übergeben

[quote=Sebastian.Herbig]im logger (cao) wird das products_userfield[7] korrekt übergeben...[/quote]
Selbstverständlich habe ich die K-Version... :-) Hast Du das in Deiner Glaskugel nicht gesehen?

Hier eine komplette Version für osCommerce.
Übertragen werden:
- EAN-Nummer (BARCODE)
- USERFIELD[1] - USERFIELD[10] (Voraussetzung K-Version)

Vorbereitung
In der Tabelle "products" müssen folgende Felder hinzugefügt werden:
"products_ean" varchar(13)
"products_userfield_1" varchar(255) --> entsprechend auch von 2 - 10 machen

Code: Alles auswählen

function ProductsUpdate ()
{
  global $_POST, $LangID;

  $products_id = tep_db_prepare_input($_POST['pID']);
  
  // product laden
  $SQL = "select products_quantity,products_model,products_ean,products_image,products_price,products_date_available,products_weight,products_status,products_tax_class_id, manufacturers_id, manufacturers_model";

  if (DREI_PRODUKTBILDER == true)
  {
    $SQL .= ", products_image_medium, products_image_large ";
  }
  $count_query = tep_db_query($SQL . " from " . TABLE_PRODUCTS . " where products_id='" . $products_id . "'");
  if ($product = tep_db_fetch_array($count_query))
  {
    $exists = 1;
    // aktuelle Produktdaten laden
    $products_quantity = $product['products_quantity'];
    $products_model = $product['products_model'];
    $products_ean = $product['products_ean'];
	$products_userfield_1 = $product['products_userfield'][1];
	$products_userfield_2 = $product['products_userfield'][2];
	$products_userfield_3 = $product['products_userfield'][3];
	$products_userfield_4 = $product['products_userfield'][4];
	$products_userfield_5 = $product['products_userfield'][5];
	$products_userfield_6 = $product['products_userfield'][6];
	$products_userfield_7 = $product['products_userfield'][7];
	$products_userfield_8 = $product['products_userfield'][8];
	$products_userfield_9 = $product['products_userfield'][9];
	$products_userfield_10 = $product['products_userfield'][10];
	$products_image = $product['products_image'];
           
    if (DREI_PRODUKTBILDER == true)
    {
      $products_image_med = $product['products_image_medium'];
      $products_image_large = $product['products_image_large'];
    }
           
    $products_price = $product['products_price'];
    $products_date_available = $product['products_date_available'];
    $products_weight = $product['products_weight'];
    $products_status = $product['products_status'];
    $products_tax_class_id = $product['products_tax_class_id'];
    $manufacturers_id = $product['manufacturers_id'];
    $manufacturers_model = $product['manufacturers_model'];
  } 
  else $exists = 0; 
        
  // Variablen nur ueberschreiben wenn als Parameter vorhanden !!!
  if (isset($_POST['products_quantity'])) $products_quantity = tep_db_prepare_input($_POST['products_quantity']);
  if (isset($_POST['products_model'])) $products_model = tep_db_prepare_input($_POST['products_model']);
  if (isset($_POST['products_ean'])) $products_ean = tep_db_prepare_input($_POST['products_ean']);
  if (isset($_POST['products_userfield'][1])) $products_userfield_1 = tep_db_prepare_input($_POST['products_userfield'][1]);
  if (isset($_POST['products_userfield'][2])) $products_userfield_2 = tep_db_prepare_input($_POST['products_userfield'][2]);
  if (isset($_POST['products_userfield'][3])) $products_userfield_3 = tep_db_prepare_input($_POST['products_userfield'][3]);
  if (isset($_POST['products_userfield'][4])) $products_userfield_4 = tep_db_prepare_input($_POST['products_userfield'][4]);
  if (isset($_POST['products_userfield'][5])) $products_userfield_5 = tep_db_prepare_input($_POST['products_userfield'][5]);
  if (isset($_POST['products_userfield'][6])) $products_userfield_6 = tep_db_prepare_input($_POST['products_userfield'][6]);
  if (isset($_POST['products_userfield'][7])) $products_userfield_7 = tep_db_prepare_input($_POST['products_userfield'][7]);
  if (isset($_POST['products_userfield'][8])) $products_userfield_8 = tep_db_prepare_input($_POST['products_userfield'][8]);
  if (isset($_POST['products_userfield'][9])) $products_userfield_9 = tep_db_prepare_input($_POST['products_userfield'][9]);
  if (isset($_POST['products_userfield'][10])) $products_userfield_10 = tep_db_prepare_input($_POST['products_userfield'][10]);

  if (isset($_POST['products_image'])) $products_image = tep_db_prepare_input($_POST['products_image']);
        
  if (DREI_PRODUKTBILDER == true)
  {
    if (isset($_POST['products_image_med'])) $products_image_med = tep_db_prepare_input($_POST['products_image_med']);
    if (isset($_POST['products_image_large'])) $products_image_large = tep_db_prepare_input($_POST['products_image_large']);
  }
        
  if (isset($_POST['products_price'])) $products_price = tep_db_prepare_input($_POST['products_price']);
  if (isset($_POST['products_date_available'])) $products_date_available = tep_db_prepare_input($_POST['products_date_available']);
  if (isset($_POST['products_weight'])) $products_weight = tep_db_prepare_input($_POST['products_weight']);
  if (isset($_POST['products_status'])) $products_status = tep_db_prepare_input($_POST['products_status']);
  if (isset($_POST['products_tax_class_id'])) $products_tax_class_id = tep_db_prepare_input($_POST['products_tax_class_id']);
  if (isset($_POST['manufacturers_id'])) $manufacturers_id = tep_db_prepare_input($_POST['manufacturers_id']);
  if (isset($_POST['manufacturers_model'])) $manufacturers_model = tep_db_prepare_input($_POST['manufacturers_model']);

  if (file_exists('cao_produpd_1.php')) { include('cao_produpd_1.php'); }
        
  $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';
          
  if (DREI_PRODUKTBILDER == true)
  {
    $sql_data_array = array('products_id' => $products_id,
                            'products_quantity' => $products_quantity,
                            'products_model' => $products_model,
                            'products_ean' => $products_ean,
							'products_userfield_1' => $products_userfield_1,
							'products_userfield_2' => $products_userfield_2,
							'products_userfield_3' => $products_userfield_3,
							'products_userfield_4' => $products_userfield_4,
							'products_userfield_5' => $products_userfield_5,
							'products_userfield_6' => $products_userfield_6,
							'products_userfield_7' => $products_userfield_7,
							'products_userfield_8' => $products_userfield_8,
							'products_userfield_9' => $products_userfield_9,
							'products_userfield_10' => $products_userfield_10,
							'products_image' => ($products_image == 'none') ? '' : $products_image,
                            'products_image_medium' => ($products_image_med == 'none') ? '' : $products_image_med,
                            'products_image_large' => ($products_image_large == 'none') ? '' : $products_image_large,
                            'products_price' => $products_price,
                            'products_date_available' => $products_date_available,
                            'products_weight' => $products_weight,
                            'products_status' => $products_status,
                            'products_tax_class_id' => $products_tax_class_id,
                            'manufacturers_id' => $manufacturers_id,
                            'manufacturers_model' => $manufacturers_model);
  }
    else
  {
    $sql_data_array = array('products_id' => $products_id,
                            'products_quantity' => $products_quantity,
                            'products_model' => $products_model,
							'products_ean' => $products_ean,
							'products_userfield_1' => $products_userfield_1,
							'products_userfield_2' => $products_userfield_2,
							'products_userfield_3' => $products_userfield_3,
							'products_userfield_4' => $products_userfield_4,
							'products_userfield_5' => $products_userfield_5,
							'products_userfield_6' => $products_userfield_6,
							'products_userfield_7' => $products_userfield_7,
							'products_userfield_8' => $products_userfield_8,
							'products_userfield_9' => $products_userfield_9,
							'products_userfield_10' => $products_userfield_10,
                            'products_image' => ($products_image == 'none') ? '' : $products_image,
                            'products_price' => $products_price,
                            'products_date_available' => $products_date_available,
                            'products_weight' => $products_weight,
                            'products_status' => $products_status,
                            'products_tax_class_id' => $products_tax_class_id,
                            'manufacturers_id' => $manufacturers_id,
                            'manufacturers_model' => $manufacturers_model);
  }
          
  if ($exists==0) // Neuanlage (ID wird an CAO zurueckgegeben !!!)
  {
    $mode='APPEND';
    $insert_sql_data = array('products_date_added' => 'now()');
    $sql_data_array = /*tep_*/array_merge($sql_data_array, $insert_sql_data);
    tep_db_perform(TABLE_PRODUCTS, $sql_data_array);
    $products_id = tep_db_insert_id();
  } 
  elseif ($exists==1) //Update
  {
    $mode='UPDATE';
    $update_sql_data = array('products_last_modified' => 'now()');
    $sql_data_array = /*tep_*/array_merge($sql_data_array, $update_sql_data);
      
    tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', 'products_id = \'' . tep_db_input($products_id) . '\'');
  }
        
  $languages = tep_get_languages();
  for ($i = 0, $n = sizeof($languages); $i < $n; $i++) 
  {
    $language_id = $languages[$i]['id'];
          
    // Bestehende Daten laden
    $SQL = "select products_id,products_name,products_description,products_url,products_viewed,language_id";
	  
    if (HEADERTAGS == true)
    {
      $SQL .= ", products_head_title_tag, products_head_desc_tag, products_head_keywords_tag";
    }
	
    $desc_query = tep_db_query($SQL . " from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id='" . $products_id . "' and language_id='" . $language_id . "'");
    if ($desc = tep_db_fetch_array($desc_query))
    {
      $products_name = $desc['products_name'];
      $products_description = $desc['products_description'];
      $products_url = $desc['products_url'];
	    
      if (HEADERTAGS == true)
      {
        $products_head_title_tag    = $desc['products_head_title_tag'];
        $products_head_desc_tag     = $desc['products_head_desc_tag'];
        $products_head_keywords_tag = $desc['products_head_keywords_tag'];	      
      }
    }
          
    // uebergebene Daten einsetzen
    if (isset($_POST['products_name'][$LangID]))              $products_name             =tep_db_prepare_input($_POST['products_name'][$LangID]);
    if (isset($_POST['products_description'][$LangID]))       $products_description      =tep_db_prepare_input($_POST['products_description'][$LangID]);
    if (isset($_POST['products_url'][$LangID]))               $products_url              =tep_db_prepare_input($_POST['products_url'][$LangID]);
	  
    if (isset($_POST['products_meta_title'][$LangID]))        $products_head_title_tag   =tep_db_prepare_input($_POST['products_meta_title'][$LangID]);	  
    if (isset($_POST['products_meta_description'][$LangID]))  $products_head_desc_tag    =tep_db_prepare_input($_POST['products_meta_description'][$LangID]);
    if (isset($_POST['products_meta_keywords'][$LangID]))     $products_head_keywords_tag=tep_db_prepare_input($_POST['products_meta_keywords'][$LangID]);    

    $sql_data_array = array('products_name' => $products_name,
                            'products_description' => $products_description,
                            'products_url' => $products_url);
          
    if (HEADERTAGS == true)
    {
      $sql_data_array2 = array('products_head_title_tag'    => $products_head_title_tag,
                               'products_head_desc_tag'     => $products_head_desc_tag,
                               'products_head_keywords_tag' => $products_head_keywords_tag);
      
      $sql_data_array = /*tep_*/array_merge($sql_data_array, $sql_data_array2); 
    }
          
    if ($exists==0) // Insert
    {
      $insert_sql_data = array('products_id' => $products_id,
                               'language_id' => $language_id);
      $sql_data_array = /*tep_*/array_merge($sql_data_array, $insert_sql_data);
      tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
    } 
    elseif (($exists==1)and($LangID==$language_id)) // Update
    {
      tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', 'products_id = \'' . tep_db_input($products_id) . '\' and language_id = \'' . $language_id . '\'');
    }
  }
  if (file_exists('cao_produpd_2.php')) { include('cao_produpd_2.php'); }
  
  print_xml_status (0, $_POST['action'], 'OK', $mode, 'PRODUCTS_ID', $products_id);
}
Habe es heute Nacht um 2:30 Uhr dann selbst entdeckt... hatte keine Lust mehr ins Forum zu posten. Wollte das am Vormittag nachholen.

Re: USERFELD an osCommerce übergeben

Hallo,


sieht noch aus als ob es mit der "heissen Nadel" gestrickt wurde, in fremden DEFINES zum teil.
Wenn schon, dann bitte mit einem eigenen DEFINE al la "DREI_PRODUKTBILDER", damit es der Anwender zu- und abschalten kann.

Ansonsten danke für deine Mühe!

Man sollte evt. noch erwähnen, das das ganze eh nur dem erfahrenen Anwender nützt, der auch in der Lage ist, die Felder aus der Datenbank wieder in seinem Shop anzeigen zu lassen.

Re: USERFELD an osCommerce übergeben

Ja, das stimmt.

Ich nutze die USERFELDER 7 - 10 um folgendes darstellen zu lassen:

USB / LAN / WLAN / Bluetooth

In den Feldern wird nur ein "x" eingetragen.
Im Shop wird das Feld dann überprüft. Wenn ein "x" eingetragen ist, dann wird das entsprechende Bildchen angezeigt.
So sieht der Kunde übersichtlich, welche Anschlußmöglichkeiten der Drucker hat.

Die Felder 1 - 6 habe ich dann natürlich auch gleich mitgemacht... wer weiß, was noch kommt :-)

Wer sehen will, wie es aussieht, kann mir ja eine kurze PM senden.
Ich möchte den Link zu meinem Shop ungern posten (Schleichwerbung, etc.)