ZenCart Products ID Search

by damonp on October 20, 2006

in Ecommerce,PHP,Snippets

The ZenCart admin does not allow searching for products by the products_id field. This is the field assigned internally to each product as it is entered by ZenCart itself.

Using the Paypal Session Viewer (updated v2 here) to debug recent Paypal issues for a client, only shows the products_id ordered without any additional product information. To make it easy to find the product in the ZenCart admin from only the products_id make the following hack in admin/includes/modules/category_product_listing.php around line #191:

Before:

    if (isset($_GET['search'])) {
      $products_query_raw = ("select p.products_type, 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,
                                       p.products_model,
                                       p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
                                       p.product_is_free, p.product_is_call, p.products_quantity_mixed,
                                       p.products_quantity_order_max, p.products_sort_order
                                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)$_SESSION['languages_id'] . "'
                                and p.products_id = p2c.products_id
                                and (
                                pd.products_name like '%"
. zen_db_input($_GET['search']) . "%'
                                or pd.products_description like '%"
. zen_db_input($_GET['search']) . "%'
                                or p.products_model like '%"
. zen_db_input($_GET['search']) . "%')" .
                                $order_by);
    } else {

After:

    if (isset($_GET['search'])) {
      $products_query_raw = ("select p.products_type, 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,
                                       p.products_model,
                                       p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
                                       p.product_is_free, p.product_is_call, p.products_quantity_mixed,
                                       p.products_quantity_order_max, p.products_sort_order
                                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)$_SESSION['languages_id'] . "'
                                and p.products_id = p2c.products_id
                                and (
                                pd.products_name like '%"
. zen_db_input($_GET['search']) . "%'
                                or pd.products_description like '%"
. zen_db_input($_GET['search']) . "%'
                                or p.products_id = '"
. zen_db_input($_GET['search']) . "'
                                or p.products_model like '%"
. zen_db_input($_GET['search']) . "%')" .
                                $order_by);
    } else {

You can see the:

or p.products_id = '" . zen_db_input($_GET['search']) . "'

added near the bottom of the snippet.

Popularity: 2%

Most Popular Posts

Damon Parker is a freelance sysadmin and web developer in Texas. He specializes in server setup, server security and high performance server configurations. Need help setting up a web server or getting a server back online after a crash or hack? Email Damon

{ 1 comment… read it below or add one }

nico October 20, 2010 at 1:27 pm

Thanks !!! It works now!

Reply

Leave a Comment

Previous post:

Next post: