Jump to content
Sign in to follow this  
jordi

[CONTRIBUTION] Admin products paging

Recommended Posts

Hi

 

Could the author be kind enough to post install instructions in English for this mod, with a step by step (my categories.php is heavilit modified, i just can't replace the entire file and need to know what has been implemented)

 

Muchos Gracias ;-)

Share this post


Link to post
Share on other sites
installed this great contribution but found a heavy bug...nstalled this great contribution but found a heavy bug...

 

for example: i have 100 products divided on 10 pages (so 10 products per side). when i want to edit a product which is on page 3 for example and i search this product via the search function and in the search results i mark the product, then the browser does NOT go to the marked product on page 3, but the browser goes back to the first page! (instead going to the page 3 where my searched product is listed)

 

or the same problem: for example: i am paging within my product sites and i mark a product on page 5, then the broswer goes back to the first page. (instead of going to the marked product on page 5)

Is this bug solved in the new version?

Kind regards

G?tz

Share this post


Link to post
Share on other sites
installed this great contribution but found a heavy bug...

 

for example: i have 100 products divided on 10 pages (so 10 products per side). when i want to edit a product which is on page 3 for example and i search this product via the search function and in the search results i mark the product, then the browser does NOT go to the marked product on page 3, but the browser goes back to the first page! (instead going to the page 3 where my searched product is listed)

 

or the same problem: for example: i am paging within my product sites and i mark a product on page 5, then the broswer goes back to the first page. (instead of going to the marked product on page 5)

This bug is still there.

So you can try this: (linenumbers refer to the last categories.php of this contribution [Jordi 3.Sep 2006])

*** RELACE ***
(line 871)

// Get categories_id for product if search
  if (isset($HTTP_GET_VARS['search'])) $cPath = $products['categories_id'];


*** WITH ***

// Get categories_id for product if search
  if (isset($HTTP_GET_VARS['search'])) {
	$cPath = $products['categories_id'];

// BOF get the right page
	$limit_query = tep_db_query("select p.products_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 p2c.categories_id = '" . $cPath . "' order by pd.products_name ");
	$limit_count=0;
	while ($limit_array = tep_db_fetch_array($limit_query)) {
	  if ($limit_array['products_id']==$products['products_id']) {
		$limi = $limit_count;
	  }
	  $limit_count++;
	}
// EOF get the right page

  } // END if (isset($HTTP_GET_VARS['search']))

and a little bit further down

*** REPLACE ***
(line 888)

	echo '			  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']. '&limite_1='.$limite_1 . '&limite_2='.$limite_2) . '\'">' . "\n";


*** WITH ***
  if (isset($HTTP_GET_VARS['search'])) {
	echo '			  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']. '&limite_1='.$limi . '&limite_2='.$limite_2) . '\'">' . "\n";
  } else {
	echo '			  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']. '&limite_1='.$limite_1 . '&limite_2='.$limite_2) . '\'">' . "\n";
  }

It will show the product in your searchresult when you click on as the first product on the next page in the right category. :thumbsup:

Share this post


Link to post
Share on other sites

Thanks, Gotz, was waiting for this solution for such a long time...works like a charm! :)

The only thing missing in this contribution now is the ability to limit the displayed (products) search results per page as well. Do you know how to do it by any chance?

Share this post


Link to post
Share on other sites
The only thing missing in this contribution now is the ability to limit the displayed (products) search results per page as well. Do you know how to do it by any chance?
Not sure about this one, as the SEARCH select has to select all matching products, the logic has to be inside the while clause...

Share this post


Link to post
Share on other sites
The only thing missing in this contribution now is the ability to limit the displayed (products) search results per page
If you have allready added my code from above, than you can add this to get the search paging:

(Note that linenumbers refer to the last categories.php of this contribution [Jordi 3.Sep 2006])

*** REPLACE ***
(line 851)


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 {


*** WITH ***


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 LIMIT $limite_1, $limite_2");
} else {



*** REPLACE ***
(line 944)

			if ( $cPath){
					// 1) calculamos el numero total de productos...
					$num_prod=tep_db_query("SELECT * from products_to_categories where categories_id='$current_category_id'");
					$np=mysql_num_rows($num_prod);
					echo "<b><font=1>".(($np>0)? "NUMERO TOTAL DE ARTICULOS EN ESTA CATEGORIA":"NO HAY ART?CULOS EN ESTA CATEGORIA")."</font></b>\n".$np;
			}


*** WITH ***


		  if ( $cPath ) {
			if (isset($HTTP_GET_VARS['search'])) {
			  $search_query = tep_db_query("SELECT COUNT(*) AS total 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) . "%' OR p.products_model like '%" . tep_db_input($search) . "%') ORDER BY pd.products_name");
			  $np = tep_db_fetch_array($search_query);
			  $np = $np['total'];
			  echo "<font=1>".(($np>0)? "Anzahl gefundene Artikel f?r diese Suchabfrage ":"Es wurden keine Artikel gefunden ")."</font><b>" . $np . "</b>";
			} else {
			  $num_prod = tep_db_query("SELECT COUNT(*) AS total FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE categories_id='" . $current_category_id . "'");
			  $np = tep_db_fetch_array($num_prod);
			  $np = $np['total'];
			  echo "<font=1>".(($np>0)? "Anzahl gefundene Artikel in dieser Kategorie ":"Es gibt keine Artikel in dieser Kategorie ")."</font><b>" . $np . "</b>";
			}
		  }


*** REPLACE ***
(line 955)

			if ( $cPath){

					// 2 calculamos la linea de paginaciones...
					$records_per_page=$lmt;
					$page_num=ceil($np/$records_per_page);
					echo "Ir a la p?gina: ";
					$lim_1=0;
					$lim_2=$lmt;
					for ($i=0; $i < $page_num; $i++)		{
							$a=$i+1;
							echo (($lim_1!=$limite_1)? "<a href=categories.php?cPath=$cPath&limite_1=$lim_1&limite_2=$lim_2>":"<u><b>");

							echo $a;

							echo (($lim_1!=$limite_1)? "</a>":"</b></u>");

							echo (($a < $page_num)? "|":"");

							$lim_1=$lim_1+$lim_2;
					}
			}


*** WITH ***


		  if ( $cPath ) {
			$records_per_page=$lmt;
			$page_num=ceil($np/$records_per_page);
			echo "Anzahl Seiten: ";
			$lim_1=0;
			$lim_2=$lmt;
			if (isset($HTTP_GET_VARS['search'])) {
			  for ($i=0; $i < $page_num; $i++) {
				$a=$i+1;
				echo (($lim_1!=$limite_1)? "<a href=categories.php?search=$search&limite_1=$lim_1&limite_2=$lim_2><u>":"<b>");
				echo $a;
				echo (($lim_1!=$limite_1)? "</u></a>":"</b>");
				echo (($a < $page_num)? "|":"");
				$lim_1=$lim_1+$lim_2;
			  }
			} else {
			  for ($i=0; $i < $page_num; $i++)		{
				$a=$i+1;
				echo (($lim_1!=$limite_1)? "<a href=categories.php?cPath=$cPath&limite_1=$lim_1&limite_2=$lim_2><u>":"<b>");
				echo $a;
				echo (($lim_1!=$limite_1)? "</u></a>":"</b>");
				echo (($a < $page_num)? "|":"");
				$lim_1=$lim_1+$lim_2;
			  }
			}
		  }

Share this post


Link to post
Share on other sites

Thanks A LOT, mate! You are my new hero! ;)

Share this post


Link to post
Share on other sites
to get the search paging:
Sorry, little correction:
*** REPLACE ***
(line 944)

			if ( $cPath){
					// 1) calculamos el numero total de productos...
					$num_prod=tep_db_query("SELECT * from products_to_categories where categories_id='$current_category_id'");
					$np=mysql_num_rows($num_prod);
					echo "<b><font=1>".(($np>0)? "NUMERO TOTAL DE ARTICULOS EN ESTA CATEGORIA":"NO HAY ART?CULOS EN ESTA CATEGORIA")."</font></b>\n".$np;
			}


*** WITH ***


		  if ( $cPath ) {
			if (isset($HTTP_GET_VARS['search'])) {
			  $search_query = tep_db_query("SELECT COUNT(*) AS total 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");
			  $np = tep_db_fetch_array($search_query);
			  $np = $np['total'];
			  echo "<font=1>".(($np>0)? "Anzahl gefundene Artikel f?r diese Suchabfrage ":"Es wurden keine Artikel gefunden ")."</font><b>" . $np . "</b>";
			} else {
			  $num_prod = tep_db_query("SELECT COUNT(*) AS total FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE categories_id='" . $current_category_id . "'");
			  $np = tep_db_fetch_array($num_prod);
			  $np = $np['total'];
			  echo "<font=1>".(($np>0)? "Anzahl gefundene Artikel in dieser Kategorie ":"Es gibt keine Artikel in dieser Kategorie ")."</font><b>" . $np . "</b>";
			}
		  }

Share this post


Link to post
Share on other sites
This bug is still there.
If you prefer to have your product displayed on the right rowposition after you cklickon in your searchresult, you can take this code instead of the above:
*** RELACE ***
(line 871)

// Get categories_id for product if search
  if (isset($HTTP_GET_VARS['search'])) $cPath = $products['categories_id'];


*** WITH ***

// Get categories_id for product if search
  if (isset($HTTP_GET_VARS['search'])) {
	$cPath = $products['categories_id'];

// BOF get the right page
	$limit_query = tep_db_query("select p.products_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 p2c.categories_id = '" . $cPath . "' order by pd.products_name ");
	$limit_count=0;
	while ($limit_array = tep_db_fetch_array($limit_query)) {
	  if ($limit_array['products_id']==$products['products_id']) {
		$limi = $limit_count;
		if ($limi > $lmt) {
		  $limi = $limi / $lmt;
		  $limi = $lmt * (int)$limi;
		} else {
		  $limi = 0;
		}
	  }
	  $limit_count++;
	}
// EOF get the right page

  } // END if (isset($HTTP_GET_VARS['search']))

Share this post


Link to post
Share on other sites

There is another bug in:

If you click on preview icon, the button_back won't know the limites...

*** REPLACE ***
line (691)

if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) {
  if (isset($HTTP_GET_VARS['origin'])) {
	$pos_params = strpos($HTTP_GET_VARS['origin'], '?', 0);
	if ($pos_params != false) {
	  $back_url = substr($HTTP_GET_VARS['origin'], 0, $pos_params);
	  $back_url_params = substr($HTTP_GET_VARS['origin'], $pos_params + 1);
	} else {
	  $back_url = $HTTP_GET_VARS['origin'];
	  $back_url_params = '';
	}
  } else {
	$back_url = FILENAME_CATEGORIES;
	$back_url_params = 'cPath=' . $cPath . '&pID=' . $pInfo->products_id;
  }
?>
  <tr>
	<td align="right"><?php echo '<a href="' . tep_href_link($back_url, $back_url_params, 'NONSSL') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
  </tr>
<?php
} else {


*** WITH ***


if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) {
  if (isset($HTTP_GET_VARS['origin'])) {
	$pos_params = strpos($HTTP_GET_VARS['origin'], '?', 0);
	if ($pos_params != false) {
	  $back_url = substr($HTTP_GET_VARS['origin'], 0, $pos_params);
	  $back_url_params = substr($HTTP_GET_VARS['origin'], $pos_params + 1);
	} else {
	  $back_url = $HTTP_GET_VARS['origin'];
	  $back_url_params = '';
	}
  } else {
	$back_url = FILENAME_CATEGORIES;
	$back_url_params = 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&limite_1=' . $limite_1 . '&limite_2=' . $limite_2;
  }
?>
  <tr>
	<td align="right"><?php echo '<a href="' . tep_href_link($back_url, $back_url_params, 'NONSSL') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
  </tr>
<?php
} else {

Share this post


Link to post
Share on other sites

Thanks. The last code causes the following SQL error when I click the back button:

"1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '$limite_1, $limite_2' at line 1

select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_cost, p.products_price1, p.products_price2, p.products_price3, p.products_price4, p.products_price1_qty, p.products_price2_qty, p.products_price3_qty, p.products_price4_qty, p.products_qty_blocks, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status 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 p2c.categories_id = '26' order by pd.products_name LIMIT $limite_1, $limite_2

 

Do you how I can fix it?

Also, I just found another similar bug in the mod. When you edit an existing product, preview it and then click the "update" button, it won't know the limits...

Edited by dr_lucas

Share this post


Link to post
Share on other sites

Hi, there is another (nicer B) ) 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

Share this post


Link to post
Share on other sites
Hi, there is another (nicer B) ) 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

 

This code is nicer and easier indeed, but it is incomplete. If you want to edit a product on page 2, for example, when you click the product the right page column (with the edit, delete, copy, move to buttons) will disappear. Same problem with the search results.

Also if you edit a product from page 2, for example, when you finish and click the update, it will redirect you to the wrong products page and also not display the right column.

Hope you can fix all these issue, I would love to have it running, as I am sure many more would...

cheers ;)

Share this post


Link to post
Share on other sites
This code is nicer and easier indeed, but it is incomplete. If you want to edit a product on page 2, for example, when you click the product the right page column (with the edit, delete, copy, move to buttons) will disappear. Same problem with the search results.

Also if you edit a product from page 2, for example, when you finish and click the update, it will redirect you to the wrong products page and also not display the right column.

Hope you can fix all these issue, I would love to have it running, as I am sure many more would...

cheers ;)

 

Thanks for your notices :). I'll check the code and fix as soon as possible...

Share this post


Link to post
Share on other sites
This code is nicer and easier indeed, but it is incomplete. If you want to edit a product on page 2, for example, when you click the product the right page column (with the edit, delete, copy, move to buttons) will disappear. Same problem with the search results.

Also if you edit a product from page 2, for example, when you finish and click the update, it will redirect you to the wrong products page and also not display the right column.

Hope you can fix all these issue, I would love to have it running, as I am sure many more would...

cheers ;)

 

If within categories.php you were to add the line

<?php require 'catalog/admin/includes/classes/split_page_results.php'); ?>

would this perhaps resolve the paging problem?

 

I will try this soon and report back.

 

Regards from wisconsin

Share this post


Link to post
Share on other sites
Thanks for your notices :). I'll check the code and fix as soon as possible...

 

Are you (or is anyone) still working on completing this contribution? I like the approach used and it would be a pity not to make it usable.

 

The last </td> in the code above should be a </tr>. That helps with the initial display but more code needs to be added around the item selection code. I'm fairly new to php so not the best person to try to fix it but I'd be happy to help test it...

Share this post


Link to post
Share on other sites
If within categories.php you were to add the line

<?php require 'catalog/admin/includes/classes/split_page_results.php'); ?>

would this perhaps resolve the paging problem?

 

I will try this soon and report back.

 

Regards from wisconsin

 

Indeed. This could be a great contribution if this bug could be fixed, but it seems this thread has been forgoten.

Has anyone found out a way to make this work??


Patty

Share this post


Link to post
Share on other sites
Indeed. This could be a great contribution if this bug could be fixed, but it seems this thread has been forgoten.

Has anyone found out a way to make this work??

 

 

i think it was very easy problem, a link must have a variable "page"

try this solution:

 

1.

line:

echo '			  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '\'">' . "\n";

 

replace:

echo '			  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '&page='.$HTTP_GET_VARS['page'].'\'">' . "\n";

 

2.

line:

<td class="dataTableContent" align="right"><?php if (isset($pInfo) && is_object($pInfo) && ($products['products_id'] == $pInfo->products_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>

 

replace:

<td class="dataTableContent" align="right"><?php if (isset($pInfo) && is_object($pInfo) && ($products['products_id'] == $pInfo->products_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&page='.$HTTP_GET_VARS['page'].'&pID=' . $products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>

Edited by skleps

Share this post


Link to post
Share on other sites

and repair changing status:

 

line:

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID']));

 

replace:

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&page='.$HTTP_GET_VARS['page'].'&pID=' . $HTTP_GET_VARS['pID']));

Share this post


Link to post
Share on other sites

Great piece of work streamlining this feature. I updated the install so that the problem with paging back to the proper page was corrected.

 

Basically, I didn't want to include page= in the url unless page actually equals something so I did it a bit different then what was done above.

 

I added: (just under the $action=)

  $page = (isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : '1');

 

like this:

$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
$page = (isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : '1');

because if the page isn't set then it's going to be 1 anyway.

 

And then I changed:

		echo '			  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '\'">' . "\n";

 

to this:

echo '			  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'page=' . $page . '&cPath=' . $cPath . '&pID=' . $products['products_id']) . '\'">' . "\n";

 

I've updated the instructions and uploaded it to the contributions page.

Share this post


Link to post
Share on other sites

Great piece of work streamlining this feature. I updated the install so that the problem with paging back to the proper page was corrected.

 

Basically, I didn't want to include page= in the url unless page actually equals something so I did it a bit different then what was done above.

 

I added: (just under the $action=)

  $page = (isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : '1');

 

like this:

$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
$page = (isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : '1');

because if the page isn't set then it's going to be 1 anyway.

 

And then I changed:

		echo '			  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '\'">' . "\n";

 

to this:

echo '			  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'page=' . $page . '&cPath=' . $cPath . '&pID=' . $products['products_id']) . '\'">' . "\n";

 

I've updated the instructions and uploaded it to the contributions page.

Share this post


Link to post
Share on other sites

Great piece of work streamlining this feature. I updated the install so that the problem with paging back to the proper page was corrected.

 

Basically, I didn't want to include page= in the url unless page actually equals something so I did it a bit different then what was done above.

 

I added: (just under the $action=)

  $page = (isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : '1');

 

like this:

$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
$page = (isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : '1');

because if the page isn't set then it's going to be 1 anyway.

 

And then I changed:

		echo '			  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '\'">' . "\n";

 

to this:

echo '			  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'page=' . $page . '&cPath=' . $cPath . '&pID=' . $products['products_id']) . '\'">' . "\n";

 

I've updated the instructions and uploaded it to the contributions page.

Share this post


Link to post
Share on other sites

Thank you for updating the contribution.

 

But I'm getting the following error when changing admin/categories.php per your instructions:

 

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/kazevedo/public_html/lojavirtual/admin/categories.php on line 859

 

How can I fix this?

 

Tks for your help and for contributing. :)

 

 

EDIT: OK, I fixed it by copying the last piece of code from here instead of the instructions in the contribution page.

But..... clicking on a product is still taking back to the first page. So the error persists.

 

Any clues?? :blink:

Edited by Patty

Patty

Share this post


Link to post
Share on other sites

This actually does it! Perfect!!

I'll update the contribution page with these instructions.

Thanks a lot, skleps! :thumbsup:

 

i think it was very easy problem, a link must have a variable "page"

try this solution:

 

1.

line:

echo '			  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '\'">' . "\n";

 

replace:

echo '			  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '&page='.$HTTP_GET_VARS['page'].'\'">' . "\n";

 

2.

line:

<td class="dataTableContent" align="right"><?php if (isset($pInfo) && is_object($pInfo) && ($products['products_id'] == $pInfo->products_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>

 

replace:

<td class="dataTableContent" align="right"><?php if (isset($pInfo) && is_object($pInfo) && ($products['products_id'] == $pInfo->products_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&page='.$HTTP_GET_VARS['page'].'&pID=' . $products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>

 

 

and repair changing status:

 

line:

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID']));

 

replace:

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&page='.$HTTP_GET_VARS['page'].'&pID=' . $HTTP_GET_VARS['pID']));


Patty

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×