Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Add model to Admin product listing


mugitty

Recommended Posts

Posted

!!! BACKUP FIRST !!!

 

All line numbers refer to an unmodified osC2.2 MS2 file

 

This modification will add the model number field to the front of each item in your Admin Product Listing Display and will allow searching on the model number, as well as the name.

 

1) In admin/categories.php, find (line 764):

              <tr class="dataTableHeadingRow">
               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CATEGORIES_PRODUCTS; ?></td>
               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
             </tr>

change it to:

              <tr class="dataTableHeadingRow">
               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>
               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CATEGORIES_PRODUCTS; ?></td>
               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
             </tr>

2) find (line 809), and add the blue text:

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p.products_model like '%" . tep_db_input($search) . "%' or p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name");

3) find (line 811), and add the blue text:

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name");

4) find (line 834):

                <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id'] . '&action=new_product_preview&read=only') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $products['products_name']; ?></td>

add immediately ABOVE it:

                <td class="dataTableContent" width="5%" nowrap><?php echo $products['products_model']; ?></td>

add to admin/includes/languages/english/categories.php

define('TABLE_HEADING_PRODUCTS_MODEL', 'Model');

If you want the listing to sort on MODEL instead of PRODUCT NAME, change the end of the queries in steps 2 and 3 above from:

order by pd.products_name

to:

order by p.products_model

... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Posted

Tried this but got error

1054 - Unknown column 'pd.products_model' in 'order clause'

select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_mediumimage, p.products_largeimage, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model from products p, products_description pd, products_to_categories p2c where p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p.products_model like '%%' or p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = '0' order by pd.products_model

[TEP STOP

 

I guess i gotta add a column somewhere, would this be in the database via MySQL?

 

If so how do I do that

Posted

Hi iantates,

 

you've got:

order by pd.products_model

 

but it looks like you should have:

order by p.products_model

(maybe a typo?)

Posted

Thanx, my eyes more like!

 

It has fixed it but now I get all my products listed as one not in separate catagories!

 

This is the section that when I add the highlighted blue it causes the problems

 

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p.products_model like '%" . tep_db_input($search) . "%' or p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name");

 

Mine current line is

 

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_mediumimage, p.products_largeimage, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name");

 

 

What do I have to change to get rid of this list

Posted

Decided to install this too and it works great, thanks very much for the tip Stuart! This should be added to the core code, very handy indeed!!! :D

 

I only made one small change:

order by p.products_model, pd.products_name

because some of my products don't have a model number. So if the model numbers are the same (or empty), it's ordered by name again.

 

 

@Ian

It has fixed it but now I get all my products listed as one not in separate catagories!
glad your order by problem is solved, don't know about your other problem, everything seems to work fine here.
Posted

Ian;

 

It looks like you're missing part of the query. The first part should read

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_mediumimage, p.products_largeimage, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model, p2c.categories_id from " . TABLE_PRODUCTS

... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Posted

So it would seem it is working right but something else has made the change!

 

 

Any ideas what would cause this

 

Screen capture of what I get

 

Image1.jpg

 

This is my top level view yet I have all the products below catagories which I didn't have before!

 

 

Ian

Posted

This one also works with MS1

 

 

you have to change the

 

<td class="dataTableContent" width="15%" nowrap><?php echo $products['products_model']; ?></td>

 

 

5% to 15% or 20% depends on the length of catagory name

 

anotherwise it looks bad.

Archived

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

×
×
  • Create New...