Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Adding data from database to product listings


digitalTag

Recommended Posts

Posted

Hi guys, i hope you can help me out.

 

I have added a new column to the table "products" called "products_from". This just contains a short string dependent on the product (i just add this manually to the database). I want this data to be displayed next to product name. I have found where this is done in product_listings.php "$listing['products_name']" so i tried doing " $listing['products_name'] . $listing['products_from'] " but this didn't work.

 

So how can i get this information out onto the page? I feel really close but i don't know php at all so i'm just coding blind.

 

digitalTag

Posted

follow following steps:

 

Insert below query in to database.

INSERT INTO configuration VALUES('', 'Display Product Form', 'PRODUCT_LIST_FORM', '4', 'Do you want to display the Product form?', 8, 1, NULL, '', NULL, NULL)

 

This query will create interface in admin for managing display of product listing.

admin=>configure=>product listing=>Display Product Form

1) find following line in index.php

$listing_sql

and ad your p.product_form field in all $listing_sql query.

 

2) find $define_list in same file and add following line in it's array.

'PRODUCT_LIST_FORM' => PRODUCT_LIST_FORM,

 

3)then fnd following line in the same file

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {

and add following case in it

case 'PRODUCT_LIST_FORM':

$select_column_list .= 'p.products_form, ';

break;

 

4)Then find following code in the ncludes/modules/product_listing.php

case 'PRODUCT_LIST_NAME':

$lc_text = TABLE_HEADING_PRODUCTS;

$lc_align = '';

break;

and add following code after it.

case 'PRODUCT_LIST_NAME':

$lc_text = TABLE_HEADING_PRODUCTS_FORM;

$lc_align = '';

break;

5) find this code in same file

case 'PRODUCT_LIST_NAME':

$listing_sql .= " order by pd.products_name " . ($sort_order == 'd' ? 'desc' : '');

break;

and add following line after it.

 

case 'PRODUCT_LIST_FORM':

$listing_sql .= " order by p.products_form " . ($sort_order == 'd' ? 'desc' : '');

break;

6) find following code in same file

 

case 'PRODUCT_LIST_NAME':

$lc_align = '';

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';

} else {

$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';

}

break;

add after above code the following code.

case 'PRODUCT_LIST_FORM':

$lc_align = 'right';

$lc_text = ' ' . $listing['products_form'] . ' ';

break;

 

 

Satish

Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site.

 

Check My About US For who am I and what My company does.

Archived

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

×
×
  • Create New...