Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution]Family Products v3.3-PHP Noob question


Recommended Posts

Posted

Hi all, first of all I like to congratulate Chris Sullivan for give us this great feature to OSC.

 

In this contribution, one new function is added to catalog/admin/includes/function/database.php its name tep_get_all_products, and this is its code:

 

function tep_get_all_products($products_array = '') {

if (!is_array($products_array)) $products_array = array();

 

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

while ($products = tep_db_fetch_array($products_query)) {

$products_array[] = array('id' => $products['products_id'], 'text' => $products['products_name']);

}

 

return $products_array;

}

 

This function works properly.

After that a new function recovers the $product_array and insert it into a "tep_draw_pull_down_menu"

My problems are:

1)I dont know PHP(the first and bigger one)

2) I have many products with the same name in my store, so when the "tep_draw_pull_down_menu" is formed many lines looks like the same(thought each one references a different product_id), so I need to include into the "tep_draw_pull_down_menu" any other aditional to "name" DB field.

 

I have tried the following, but it doesn't work:

 

function tep_get_all_products($products_array = '') {

if (!is_array($products_array)) $products_array = array();

 

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

while ($products = tep_db_fetch_array($products_query)) {

$products_array[] = array('id' => $products['products_id'], 'text' => $products['products_name'], $products['products_modelo']);

}

 

return $products_array;

}

 

Anybody can help me? I am lookin into PHP manuals(arrays sections) and I don't see any useful info for me.

 

Thanks Juan Carlos

Posted

Yupee!!!

I found it. A silly thing for php developers but maybe useful for other php noobs like me.

There is the function that works for me:

 

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

while ($products = tep_db_fetch_array($products_query)) {

$products_array[] = array('id' => $products['products_id'], 'text' => $products['products_name'] . ' ' . $products['products_modelo']);

}

 

return $products_array;

}

 

REPLACE THE products_modelo field for your desired to show field.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...