Hi, there is another (nicer) method of splitting product listing
in the Admin Side Area, using standatd osCommerce
splitPageResults class:
Instructions:
1. backup, backup
2. execute following SQL command (for example in phpMyAdmin)
# Important:
# BEFORE DO THE SCRIPT KIDDY , please back-up your data!!!!!
# AND V-E-R-I-F-Y IF THE 'CONFIGURATION_GROUP_ID' FOR MAXIMUM VALUES IS '3'
# iF NOT FIND IT AND CHANGE THE VALUE HERE OR THE CONFIGURATION-LINK WILL APPARE IN OTHER MENU
INSERT INTO `configuration` ( `configuration_id` , `configuration_title` , `configuration_key` , `configuration_value` , `configuration_description` , `configuration_group_id` , `sort_order` , `last_modified` , `date_added` , `use_function` , `set_function` )
VALUES (
'', 'Max products per page admin-side', 'MAX_PROD_ADMIN_SIDE', '30', 'Maximum number of products per page in administration panel', '3', NULL , '2003-11-10 14:54:12', '2003-11-10 14:54:12', NULL , NULL
);
3. open catalog/admin.categories.php
a. find the following lines:
(~807 on clean install)
$products_count = 0;
if (isset($HTTP_GET_VARS['search'])) {
$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, 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 pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name");
} else {
$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 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");
}
and replace with the following code:
$products_count = 0;
if (isset($HTTP_GET_VARS['search'])) {
$prod_sql = "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, 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 pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name";
} else {
$prod_sql = "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 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";
}
//BOF Admin product paging
$prod_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_PROD_ADMIN_SIDE, $prod_sql, $prod_query_numrows);
//EOF Admin product paging
$products_query = tep_db_query($prod_sql);
Notice for users having heavy modified osCommerces:
---------------------------------------------------
idea is to replace the queries denoted $products_query = tep_db_query("modified query") only with SQL query string
so $products_query = tep_db_query("modified query") becomes $prod_sql = "modified query". The query is executed
later $products_query = tep_db_query($prod_sql);
b. find the following code
(~859 on clean install)
$cPath_back = (tep_not_null($cPath_back)) ? 'cPath=' . $cPath_back . '&' : '';
?>
and replace it with the following code:
$cPath_back = (tep_not_null($cPath_back)) ? 'cPath=' . $cPath_back . '&' : '';
?>
<? //BOF Admin product paging ?>
<tr>
<td colspan="3">
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="smallText" valign="top"><?php echo $prod_split->display_count($prod_query_numrows, MAX_PROD_ADMIN_SIDE, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="smallText" align="right"><?php echo $prod_split->display_links($prod_query_numrows, MAX_PROD_ADMIN_SIDE, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page'))); ?></td>
</tr>
</table>
</td>
</td>
<? //EOF Admin product paging ?>
3. That's it!. Now on admin product/categories pages will be splitted according to the settings
Author:
mastergigi
prychl@o2.pl