Skip to content


ZenCart Products ID Search

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: 11% [?]

Posted in Ecommerce, PHP, Snippets.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.