quantity mod attribute errore RESTOCK!

Postate qui discussioni di carattere generale riguardo a problemi di installazione e configurazione di osCommerce

Moderatore: mod Generali

Rispondi
Avatar utente
castway
membro Junior
membro Junior
Messaggi: 48
Iscritto il: 14/08/2006, 14:05
Località: Venezia provincia
Contatta:

quantity mod attribute errore RESTOCK!

Messaggio 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?
Avatar utente
marcus
membro Master
membro Master
Messaggi: 1619
Iscritto il: 04/12/2003, 1:00
Contatta:

Re: quantity mod attribute errore RESTOCK!

Messaggio 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
Nuovo pacchetto osCommercePRO (osCPRO) + Modulo Interfacciamento Gestionale Danea.
Visita la demo: http://oscpro.oscommercedev.com/index.php
Avatar utente
castway
membro Junior
membro Junior
Messaggi: 48
Iscritto il: 14/08/2006, 14:05
Località: Venezia provincia
Contatta:

Messaggio da castway »

ho provato ora non da errori, ma la quantità non la ripristina..
Avatar utente
marcus
membro Master
membro Master
Messaggi: 1619
Iscritto il: 04/12/2003, 1:00
Contatta:

Messaggio 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
Nuovo pacchetto osCommercePRO (osCPRO) + Modulo Interfacciamento Gestionale Danea.
Visita la demo: http://oscpro.oscommercedev.com/index.php
Avatar utente
castway
membro Junior
membro Junior
Messaggi: 48
Iscritto il: 14/08/2006, 14:05
Località: Venezia provincia
Contatta:

Messaggio 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?
Avatar utente
castway
membro Junior
membro Junior
Messaggi: 48
Iscritto il: 14/08/2006, 14:05
Località: Venezia provincia
Contatta:

Messaggio 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
Rispondi