You are here:  » Pagination in admin panel


Pagination in admin panel

Submitted by safari45 on Thu, 2020-06-11 14:17 in

I have more than 100 000 products which have EAN and would like to create a niche website but the biggest challenge can be found in admin panel. I wonder if there can be some pagination of products in admin similar to this on this website
{link saved}

Submitted by support on Fri, 2020-06-12 07:00

Hi,

Filtering by letter is straight forward but I wasn't sure what are of admin you wanted to apply a filter / pagination similar to the example to...

I know you have been using the script for many years now and the admin panel has moved on quite a long way so if you weren't running the latest distribution (no need to upgrade and as you know I don't normally recommend that approach because of the number of modifications I help users with) what I would suggest would be to install the latest distribution in a sub-directory e.g. /pt/.

Once upload, edit config.php and set $config_baseHREF at line 6 as follows;

  $config_baseHREF = "/pt/";

...and make the $config_database* settings the same as your main installation. That's it - no need to upload or register any feeds, the /pt/admin/ home page will show all feeds as requiring registration but the rest of the admin tools will work and look at your existing database. From there, if there is anywhere that filter / pagination will help in building your niche sites let me know and I'll try and point you in the right direction...

Cheers,
David.
--
PriceTapestry.com

Submitted by safari45 on Sun, 2020-06-14 09:33

Hi David,
Thanks for reply.
I will give another example for better understanding. in search result you can configure the number of products that can be shown per page. This is not the case when it comes to admin panel (product management section). This will be very hard and time consuming if I have over 200 mapped categories and they are all listed on one page.

What about 5000 products mapped in the admin panel? they will all be listed on one page, there are no option of search for specific product or any sort of pagination in the admin if i want to edit a specific product, currently there no other way than to simply scroll through 5000 records listed on one page.

If there can be a way to control the number of products displayed per page in admin + possibility of search through products too that will be great (in product/category management section).

Submitted by support on Mon, 2020-06-15 08:26

Hi,

A filter by first letter / search box can be added to Product, Brand and Category Mapping easily - for Product Mapping, edit admin/productsmap.php and look for the following code at line 62:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."productsmap` ".$where." ORDER BY name";

...and REPLACE with:

  $q = (isset($_GET["q"])?$_GET["q"]:"");
  $l = (isset($_GET["l"])?$_GET["l"]:"");
  $sql = "SELECT DISTINCT(SUBSTR(name,1,1)) AS letter FROM `".$config_databaseTablePrefix."productsmap` ORDER BY letter";
  $letters = "";
  if (database_querySelect($sql,$rows))
  {
    foreach($rows as $row)
    {
      $letters .= "<a style='margin-left:0' class='button tiny radius ".($l==$row["letter"]?"":"secondary")."' href='?l=".$row["letter"]."'>".$row["letter"]."</a>";
    }
  }
  print "<h3>Filter</h3>";
  widget_formBegin("GET");
  widget_textBox($letters,"q",TRUE,$q,"",3);
  widget_formButtons(array("Search"=>TRUE));
  widget_formEnd();
  if ($q)
  {
    $where = " WHERE name LIKE '%".database_safe($q)."%'";
  }
  elseif ($l)
  {
    $where = " WHERE name LIKE '".database_safe($l)."%'";
  }
  else
  {
    $where = "";
  }
  $sql = "SELECT * FROM `".$config_databaseTablePrefix."productsmap` ".$where." ORDER BY name";

And for admin/brands.php; look for the following code at line 57:

  print "<h3>".translate("Existing Brands")."</h3>";
  $sql = "SELECT * FROM `".$config_databaseTablePrefix."brands` ORDER BY name";

...and REPLACE with:

  $q = (isset($_GET["q"])?$_GET["q"]:"");
  $l = (isset($_GET["l"])?$_GET["l"]:"");
  $sql = "SELECT DISTINCT(SUBSTR(name,1,1)) AS letter FROM `".$config_databaseTablePrefix."brands` ORDER BY letter";
  $letters = "";
  if (database_querySelect($sql,$rows))
  {
    foreach($rows as $row)
    {
      $letters .= "<a style='margin-left:0' class='button tiny radius ".($l==$row["letter"]?"":"secondary")."' href='?l=".$row["letter"]."'>".$row["letter"]."</a>";
    }
  }
  print "<h3>Filter</h3>";
  widget_formBegin("GET");
  widget_textBox($letters,"q",TRUE,$q,"",3);
  widget_formButtons(array("Search"=>TRUE));
  widget_formEnd();
  if ($q)
  {
    $where = " WHERE name LIKE '%".database_safe($q)."%'";
  }
  elseif ($l)
  {
    $where = " WHERE name LIKE '".database_safe($l)."%'";
  }
  else
  {
    $where = "";
  }
  $sql = "SELECT * FROM `".$config_databaseTablePrefix."brands` ".$where." ORDER BY name";
  print "<h3>".translate("Existing Brands")."</h3>";

And for admin/categories.php; look for the following code at line 57:

  print "<h3>".translate("Existing Categories")."</h3>";
  $sql = "SELECT * FROM `".$config_databaseTablePrefix."categories` ORDER BY name";

...and REPLACE with:

  $q = (isset($_GET["q"])?$_GET["q"]:"");
  $l = (isset($_GET["l"])?$_GET["l"]:"");
  $sql = "SELECT DISTINCT(SUBSTR(name,1,1)) AS letter FROM `".$config_databaseTablePrefix."categories` ORDER BY letter";
  $letters = "";
  if (database_querySelect($sql,$rows))
  {
    foreach($rows as $row)
    {
      $letters .= "<a style='margin-left:0' class='button tiny radius ".($l==$row["letter"]?"":"secondary")."' href='?l=".$row["letter"]."'>".$row["letter"]."</a>";
    }
  }
  print "<h3>Filter</h3>";
  widget_formBegin("GET");
  widget_textBox($letters,"q",TRUE,$q,"",3);
  widget_formButtons(array("Search"=>TRUE));
  widget_formEnd();
  if ($q)
  {
    $where = " WHERE name LIKE '%".database_safe($q)."%'";
  }
  elseif ($l)
  {
    $where = " WHERE name LIKE '".database_safe($l)."%'";
  }
  else
  {
    $where = "";
  }
  $sql = "SELECT * FROM `".$config_databaseTablePrefix."categories` ".$where." ORDER BY name";
  print "<h3>".translate("Existing Categories")."</h3>";

Cheers,
David.
--
PriceTapestry.com

Submitted by safari45 on Mon, 2020-06-15 21:07

Thanks David, It works like charm. I hope this will become a part of the system in future versions.