Pagina 1 di 1
quantity mod attribute errore RESTOCK!
Inviato: 07/07/2007, 18:16
da castway
Ciao a tutti ho urgente bisogno che qualcuno mi aiuti con questo errore:
1052 - Column 'products_options_id' in field list is ambiguous
SELECT products_options_id, products_options_values_id FROM orders_products_attributes LEFT JOIN products_options ON products_options_name = products_options LEFT JOIN products_options_values ON products_options_values_name = products_options_values WHERE orders_products_id = '25'
[TEP STOP]
Appare sempre quando vado a cancellare un ordine con l'opzione restock (ripristina quantità)
Il codice in questione dovrebbe essere nel file:
admin\includes\functions\general.php
il codice è:
Codice: Seleziona tutto
// START FIXING BUG TAAJNY
//$order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
$order_query = tep_db_query("select products_id, products_quantity, orders_products_id from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
while ($order = tep_db_fetch_array($order_query)) {
$options_query = tep_db_query("SELECT products_options_id, products_options_values_id FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " ON products_options_name = products_options LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " ON products_options_values_name = products_options_values WHERE orders_products_id = '" . (int)$order['orders_products_id'] . "'");
$option = tep_db_fetch_array($options_query);
tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set options_quantity = options_quantity + " . $order['products_quantity'] . " where products_id = '" . (int)$order['products_id']. "' AND options_id = '" . (int)$option['products_options_id'] . "' AND options_values_id = '" . $option['products_options_values_id'] ."'");
// END FIXING BUG TAAJNY
qualcuno sa aiutarmi?
Re: quantity mod attribute errore RESTOCK!
Inviato: 07/07/2007, 20:51
da marcus
castway ha scritto:Ciao a tutti ho urgente bisogno che qualcuno mi aiuti con questo errore:
1052 - Column 'products_options_id' in field list is ambiguous
SELECT products_options_id, products_options_values_id FROM orders_products_attributes LEFT JOIN products_options ON products_options_name = products_options LEFT JOIN products_options_values ON products_options_values_name = products_options_values WHERE orders_products_id = '25'
[TEP STOP]
Appare sempre quando vado a cancellare un ordine con l'opzione restock (ripristina quantità)
Il codice in questione dovrebbe essere nel file:
admin\includes\functions\general.php
il codice è:
Codice: Seleziona tutto
// START FIXING BUG TAAJNY
//$order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
$order_query = tep_db_query("select products_id, products_quantity, orders_products_id from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
while ($order = tep_db_fetch_array($order_query)) {
$options_query = tep_db_query("SELECT products_options_id, products_options_values_id FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " ON products_options_name = products_options LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " ON products_options_values_name = products_options_values WHERE orders_products_id = '" . (int)$order['orders_products_id'] . "'");
$option = tep_db_fetch_array($options_query);
tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set options_quantity = options_quantity + " . $order['products_quantity'] . " where products_id = '" . (int)$order['products_id']. "' AND options_id = '" . (int)$option['products_options_id'] . "' AND options_values_id = '" . $option['products_options_values_id'] ."'");
// END FIXING BUG TAAJNY
qualcuno sa aiutarmi?
Prova a sostituire la query con questa:
Codice: Seleziona tutto
$options_query = tep_db_query("SELECT opa.products_options_id, opa.products_options_values_id FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " opa LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " po ON po.products_options_name = opa.products_options LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " poa ON poa.products_options_values_name = opa.products_options_values WHERE opa.orders_products_id ='" . (int)$order['orders_products_id'] . "'");
Saluti
Marcus
Inviato: 08/07/2007, 12:02
da castway
ho provato ora non da errori, ma la quantità non la ripristina..
Inviato: 08/07/2007, 20:08
da marcus
castway ha scritto:ho provato ora non da errori, ma la quantità non la ripristina..
Il codice della query è corretto e non ho elementi per trovare la causa dell'errore logico.
Controlla i valori delle variabili a run time.
Saluti
Marcus
Inviato: 09/07/2007, 13:14
da castway
ma sul file priginale c'è scritto:
Codice: Seleziona tutto
if ($restock == 'on') {
$order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
while ($order = tep_db_fetch_array($order_query)) {
tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity + " . $order['products_quantity'] . ", products_ordered = products_ordered - " . $order['products_quantity'] . " where products_id = '" . (int)$order['products_id'] . "'");
}
}
e sul mio:
Codice: Seleziona tutto
if ($restock == 'on') {
// START FIXING BUG TAAJNY
//$order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
$order_query = tep_db_query("select products_id, products_quantity, orders_products_id from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
while ($order = tep_db_fetch_array($order_query)) {
// $options_query = tep_db_query("SELECT products_options_id, products_options_values_id FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " ON products_options_name = products_options LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " ON products_options_values_name = products_options_values WHERE orders_products_id = '" . (int)$order['orders_products_id'] . "'");
$options_query = tep_db_query("SELECT opa.products_options_id, opa.products_options_values_id FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " opa LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " po ON po.products_options_name = opa.products_options LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " poa ON poa.products_options_values_name = opa.products_options_values WHERE opa.orders_products_id ='" . (int)$order['orders_products_id'] . "'");
$option = tep_db_fetch_array($options_query);
tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set options_quantity = options_quantity + " . $order['products_quantity'] . " where products_id = '" . (int)$order['products_id']. "' AND options_id = '" . (int)$option['products_options_id'] . "' AND options_values_id = '" . $option['products_options_values_id'] ."'");
// END FIXING BUG TAAJNY
}
}
mi sembra di capire che sul mio ci sia solo l'update per l'attributo, manca l'update per ripristinare la quantità del prodotto o sbaglio?
Inviato: 09/07/2007, 13:24
da castway
ho ripristinato il codice così:
Codice: Seleziona tutto
function tep_remove_order($order_id, $restock = false) {
if ($restock == 'on') {
// START FIXING BUG TAAJNY
//$order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
$order_query = tep_db_query("select products_id, products_quantity, orders_products_id from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
while ($order = tep_db_fetch_array($order_query)) {
//$options_query = tep_db_query("SELECT products_options_id, products_options_values_id FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " ON products_options_name = products_options LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " ON products_options_values_name = products_options_values WHERE orders_products_id = '" . (int)$order['orders_products_id'] . "'");
$options_query = tep_db_query("SELECT opa.products_options_id, opa.products_options_values_id FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " opa LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " po ON po.products_options_name = opa.products_options LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " poa ON poa.products_options_values_name = opa.products_options_values WHERE opa.orders_products_id ='" . (int)$order['orders_products_id'] . "'");
$option = tep_db_fetch_array($options_query);
tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set options_quantity = options_quantity + " . $order['products_quantity'] . " where products_id = '" . (int)$order['products_id']. "' AND options_id = '" . (int)$option['products_options_id'] . "' AND options_values_id = '" . $option['products_options_values_id'] ."'");
// END FIXING BUG TAAJNY
tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity + " . $order['products_quantity'] . ", products_ordered = products_ordered - " . $order['products_quantity'] . " where products_id = '" . (int)$order['products_id'] . "'");
}
}
//begin PayPal_Shopping_Cart_IPN
include_once(DIR_FS_CATALOG_MODULES . 'payment/paypal/functions/general.func.php');
paypal_remove_order($order_id);
//end PayPal_Shopping_Cart_IPN
tep_db_query("delete from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "'");
tep_db_query("delete from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . (int)$order_id . "'");
tep_db_query("delete from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "'");
}
sembra funzionare almeno per i prodotti senza attributi, testerò meglio quando ho più tempo
intanto grazie