Zen Cart Logo
Forums / General Questions / Products Purchased Reports Search

Products Purchased Reports Search

Locked

Views: 1,287

Results 1 to 1 of 1
This thread is locked. New replies are disabled.
9 Nov 2006, 6:40 PM
#1
damonp avatar

damonp

New Zenner

Join Date:
Mar 2004
Posts:
54
Plugin Contributions:
0

Products Purchased Reports Search

Here is a little snippet to add searching to the products purchased report.

Add this form near the top of admin/stats_products_purchased.php [Line ~#64]

<tr>
<form action="stats_products_purchased.php" method="get">
<td align="right">
<b>Search</b>
<input type="text" name="search" value="<?php echo $_GET['search']; ?>"/>
<input type="submit" value="Go" />
</td>
</form>
</tr>

Mod the query to use the search [Line ~#84]:

if (isset($_GET['page']) && ($_GET['page'] > 1)) $rows = $_GET['page'] * MAX_DISPLAY_SEARCH_RESULTS_REPORTS - MAX_DISPLAY_SEARCH_RESULTS_REPORTS;
 
//11/03/06 21:40  damonp add search
   if($_GET['search'] != '')  {
      $db_search = "AND (pd.products_id = '".$_GET['search']."' OR pd.products_name LIKE '%".$_GET['search']."%')";
   }
// The following OLD query only considers the "products_ordered" value from the products table.
// Thus this older query is somewhat deprecated
  $products_query_raw = "select p.products_id, p.products_ordered, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $_SESSION['languages_id']. "' and p.products_ordered > 0 $db_search group by pd.products_id order by p.products_ordered DESC, pd.products_name";

Full details at:
http://damonparker.org/blog/2006/11/09/zencart-reports-search-function/