Attribute managen

Du hast ein PHP-Code Problem und benötigst Hilfe bei der Lösung
Antworten
Rainer
Beiträge: 102
Registriert: Sa 5. Feb 2011, 10:17
Shop Version: 1.0.14

Attribute managen

Beitrag von Rainer »

Hallo,

wenn ich die Attribute edititen will kommt ja immer eine Liste aller attribute wo die Produktattribute irgendwo auf der Seite stehen.
Das ganze wird ja durch die new_attributes_include.php erledigt.

So ich möchte jetzt natürlich nicht die ganze Liste sehen sondern nur noch die Attribute des jeweiligen Produkts.
In der tabelle products_attributes sind ja options_id und die options_values id enthalten.

Durch

Code: Alles auswählen

// Lets get all of the possible options
$query1 = "SELECT * FROM " .TABLE_PRODUCTS_ATTRIBUTES.  " where " .products_id. "=" .$_POST['current_product_id'];


$result_neu = xtc_db_query($query1);
$line_neu = xtc_db_fetch_array($result_neu);
$matches_neu = '';
$matches_neu = $line_neu['options_id'];



echo  $matches_neu;
echo " test ";
echo  $_POST['current_product_id']; 
//$query = "SELECT * FROM " . TABLE_PRODUCTS_OPTIONS . " where products_options_id LIKE '%' AND language_id = '" . $_SESSION['languages_id'] . "'";
$query = "SELECT * FROM " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $matches_neu . "' AND language_id = '" . $_SESSION['languages_id'] . "'";
habe ich das ganze schon auf die options_id eingegrenzt.

Damit nur noch die Optionen des Produkts angezeigt werden muss ja das ganze nochmals überarbeitet werden. Wie muss der code für das array uund dann die loop aussehen damit ich beim query1 nicht nur die options id sondern auch alle options_valus_id auslese und dann die Tabelle aufgebaut und der nachstehende Code ersetzt wird.

Code: Alles auswählen

if ($matches) {
		while ($line = xtc_db_fetch_array($result)) {
			$current_product_option_name = $line['products_options_name'];
			$current_product_option_id = $line['products_options_id'];
			// Print the Option Name
			echo "<TR class=\"dataTableHeadingRow\">";
			echo "<TD class=\"dataTableHeadingContent\"><B>" . $current_product_option_name . "</B></TD>";
			echo "<TD class=\"dataTableHeadingContent\"><B>" . SORT_ORDER . "</B></TD>";
			echo "<TD class=\"dataTableHeadingContent\"><B>" . ATTR_MODEL . "</B></TD>";
			echo "<TD class=\"dataTableHeadingContent\"><B>" . ATTR_STOCK . "</B></TD>";
			echo "<TD class=\"dataTableHeadingContent\"><B>" . ATTR_WEIGHT . "</B></TD>";
			echo "<TD class=\"dataTableHeadingContent\"><B>" . ATTR_PREFIXWEIGHT . "</B></TD>";
			echo "<TD class=\"dataTableHeadingContent\"><B>" . ATTR_PRICE . "</B></TD>";
			echo "<TD class=\"dataTableHeadingContent\"><B>".ATTR_BASIC_PRICE_UNIT."</B></TD>";
	        echo "<TD class=\"dataTableHeadingContent\"><B>".ATTR_BASIC_PRICE_div."</B></TD>";
            echo "<TD class=\"dataTableHeadingContent\"><B>".ATTR_BASIC_PRICE_mul."</B></TD>";
			echo "<TD class=\"dataTableHeadingContent\"><B>" . ATTR_PREFIXPRICE . "</B></TD>";

			echo "</TR>";

			// Find all of the Current Option's Available Values
			//$query2 = "SELECT * FROM " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " WHERE products_options_id = '" . $current_product_option_id . "' ORDER BY products_options_values_id DESC";
			$query2 = "SELECT * FROM " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " WHERE products_options_id = '" . $matches_neu. "' ORDER BY products_options_values_id DESC";
			$result2 = xtc_db_query($query2);
			$matches2 = xtc_db_num_rows($result2);

			if ($matches2) {
				$i = '0';
				while ($line = xtc_db_fetch_array($result2)) {
					$i++;
					$rowClass = rowClass($i);
					$current_value_id = $line['products_options_values_id'];
					$isSelected = checkAttribute($current_value_id, $_POST['current_product_id'], $current_product_option_id);
					if ($isSelected) {
						$CHECKED = ' CHECKED';
					} else {
						$CHECKED = '';
					}

					$query3 = "SELECT * FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . " WHERE products_options_values_id = '" . $current_value_id . "' AND language_id = '" . $_SESSION['languages_id'] . "'";
					$result3 = xtc_db_query($query3);
					while ($line = xtc_db_fetch_array($result3)) {
						$current_value_name = $line['products_options_values_name'];
						// Print the Current Value Name
						echo "<TR class=\"" . $rowClass . "\">";
						echo "<TD class=\"main\">";
						echo "<input type=\"checkbox\" name=\"optionValues[]\" value=\"" . $current_value_id . "\"" . $CHECKED . ">&nbsp;&nbsp;" . $current_value_name . "&nbsp;&nbsp;";
						echo "</TD>";
						echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_sortorder\" value=\"" . $sortorder . "\" size=\"4\"></TD>";
						echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_model\" value=\"" . $attribute_value_model . "\" size=\"15\"></TD>";
						echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_stock\" value=\"" . $attribute_value_stock . "\" size=\"4\"></TD>";
						echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_weight\" value=\"" . $attribute_value_weight . "\" size=\"10\"></TD>";
						echo "<TD class=\"main\" align=\"left\"><SELECT name=\"" . $current_value_id . "_weight_prefix\"><OPTION value=\"+\"" . $posCheck_weight . ">+<OPTION value=\"-\"" . $negCheck_weight . ">-</SELECT></TD>";

						// brutto Admin
						if (PRICE_IS_BRUTTO == 'true') {
							$attribute_value_price_calculate = $xtPrice->xtcFormat(xtc_round($attribute_value_price * ((100 + (xtc_get_tax_rate(xtc_get_tax_class_id($_POST['current_product_id'])))) / 100), PRICE_PRECISION), false);
						} else {
							$attribute_value_price_calculate = xtc_round($attribute_value_price, PRICE_PRECISION);
						}
						echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_price\" value=\"" . $attribute_value_price_calculate . "\" size=\"10\">";
					 	echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" .$current_value_id . "_basic_price_unit\" value=\"" . $attribute_value_basic_price_unit . "\" size=\"10\"></TD>"; 
            echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" .$current_value_id . "_basic_price_div\" value=\"" . $attribute_value_basic_price_div . "\" size=\"10\"></TD>"; 
            echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" .$current_value_id . "_basic_price_mul\" value=\"" . $attribute_value_basic_price_mul . "\" size=\"10\"></TD>";
          
          
          	// brutto Admin
						if (PRICE_IS_BRUTTO == 'true') {
							echo TEXT_NETTO . '<b>' . $xtPrice->xtcFormat(xtc_round($attribute_value_price, PRICE_PRECISION), true) . '</b>  ';
						}

						echo "</TD>";

						echo "<TD class=\"main\" align=\"left\"><SELECT name=\"" . $current_value_id . "_prefix\"> <OPTION value=\"+\"" . $posCheck . ">+<OPTION value=\"-\"" . $negCheck . ">-</SELECT></TD>";



						echo "</TR>";
						// Download function start
						if (strtoupper($current_product_option_name) == 'DOWNLOADS') {
							echo "<tr>";

							// echo "<td colspan=\"2\">File: <input type=\"file\" name=\"" . $current_value_id . "_download_file\"></td>";
							echo "<td colspan=\"2\">" . xtc_draw_pull_down_menu($current_value_id . '_download_file', xtc_getDownloads(), $attribute_value_download_filename, '') . "</td>";
							echo "<td class=\"main\">&nbsp;" . DL_COUNT . " <input type=\"text\" name=\"" . $current_value_id . "_download_count\" value=\"" . $attribute_value_download_count . "\"></td>";
							echo "<td class=\"main\">&nbsp;" . DL_EXPIRE . " <input type=\"text\" name=\"" . $current_value_id . "_download_expire\" value=\"" . $attribute_value_download_expire . "\"></td>";
							echo "</tr>";
						}
						// Download function end
					}
					if ($i == $matches2)
						$i = '0';
				}
			} else {
				echo "<TR>";
				echo "<TD class=\"main\"><SMALL>No values under this option.</SMALL></TD>";
				echo "</TR>";
			}
		}
	}
Freundlich grüßt

Rainer
Antworten