Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

New function to get products


Salvo

Recommended Posts

Posted

Hi all, I am trying to get the product with a new function, but it doesn't work.

 

Can someone look at it>

thanks

 

function tep_get_products($default = '') {

$products_array = array();

if ($default) {

$products_array[] = array('id' => '',

'text' => $default);

}

$products_query2 = tep_db_query("select p.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by products_name");

while ($products2 = tep_db_fetch_array($products_query2)) {

$products_array[] = array('id' => $products2['products_id'],

'text' => $products2['products_name']);

}

return $products_array;

}

Posted

Hi all

 

I have found the reason why it wasn't working, but I don't understand why

 

In admin/includes/funcions/genenral.php

 

This doesn't work

 

$products_query = tep_db_query("select p.products_id, pd.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by products_name");

 

 

THIS WORKS OK

 

$products_query = tep_db_query("select p.products_id, pd.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id order by products_name");

 

Can someone tell me why the (int)$languages_id is not picked up?

 

Thanks

Posted

I guess you have to add:

   global $languages_id;

because you are working inside a function. Otherwise the variable is empty and therefore you don't get a result from the query.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...