Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Displaying Product Viewed in Product Listing Page

Displaying Product Viewed in Product Listing Page

Views: 2,477

Results 1 to 20 of 37
17 Apr 2015, 11:18 AM
#1
eric_chen avatar

eric_chen

New Zenner

Join Date:
May 2012
Posts:
39
Plugin Contributions:
0

Displaying Product Viewed in Product Listing Page

Hello,

I'm totally new on PHP and I want to show the products_viewed counter under the buy now button in prodcut listing page,
and I use following code by Mr. Ajeh in this thread:
https://www.zen-cart.com/showthread.php?181318-Displaying-Product-Viewed-in-the-product_info_diplay:

 <?php echo ( zen_products_lookup((int)$_GET['products_id'], 'products_viewed') > 0 ? '<li>' . 'Views: ' . zen_products_lookup((int)$_GET['products_id'], 'products_viewed') . '</li>' : '') . "\n"; ?>

But it seems not working. I have tried in product info page and it is working.
I did a search for my problem but there are no any related result...

Thank youuuu

17 Apr 2015, 1:11 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Displaying Product Viewed in Product Listing Page

On the products_listing you could use in the file:
/includes/modules/your_template_dir/product_listing.php

in place of the line for the Price:

        case 'PRODUCT_LIST_PRICE':
[B]        $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
[/B]        $lc_align = 'right';
        $lc_text =  $lc_price;

the code in RED:

        case 'PRODUCT_LIST_PRICE':
[B]        $lc_price = zen_get_products_display_price($listing->fields['products_id']) .
 ( zen_products_lookup($listing->fields['products_id'], 'products_viewed') > 0 ? '<li>' . 'Views: ' . zen_products_lookup($listing->fields['products_id'], 'products_viewed') . '</li>' : '') . '<br />';
[/B]        $lc_align = 'right';
        $lc_text =  $lc_price;

and adjust it as needed ...

17 Apr 2015, 3:11 PM
#3
eric_chen avatar

eric_chen

New Zenner

Join Date:
May 2012
Posts:
39
Plugin Contributions:
0

Re: Displaying Product Viewed in Product Listing Page

I just replaced the above code, and indeed viewed counter is showed with each product on the product list. But each product has same viewed counts which seem from
first product (products_id with 1) in my store. Please what is the problem??? Thanks.

17 Apr 2015, 3:31 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Displaying Product Viewed in Product Listing Page

Could you post your changes that you made to your products_listing.php file?

17 Apr 2015, 3:46 PM
#5
eric_chen avatar

eric_chen

New Zenner

Join Date:
May 2012
Posts:
39
Plugin Contributions:
0

Re: Displaying Product Viewed in Product Listing Page

Sure. I replaced and revised above code with the line of Product Model. Following are the full code of my products_listing.php file:

<?php
/**
 * product_listing module
 *
 * @package modules
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: product_listing.php 4655 2006-10-02 01:02:38Z ajeh $
 * UPDATED TO WORK WITH COLUMNAR PRODUCT LISTING For Zen Cart v1.3.6 - 10/25/2006
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
// Column Layout Support originally added for Zen Cart v 1.1.4 by Eric Stamper - 02/14/2004
// Upgraded to be compatible with Zen-cart v 1.2.0d by Rajeev Tandon - Aug 3, 2004
// Column Layout Support (Grid Layout) upgraded for v1.3.0 compatibility DrByte 04/04/2006
//
if (!defined('PRODUCT_LISTING_LAYOUT_STYLE')) define('PRODUCT_LISTING_LAYOUT_STYLE','rows');
if (!defined('PRODUCT_LISTING_COLUMNS_PER_ROW')) define('PRODUCT_LISTING_COLUMNS_PER_ROW',3);
$row = 0;
$col = 0;
$list_box_contents = array();
$title = '';
$max_results = (PRODUCT_LISTING_LAYOUT_STYLE=='columns' && PRODUCT_LISTING_COLUMNS_PER_ROW>0) ? (PRODUCT_LISTING_COLUMNS_PER_ROW * (int)(MAX_DISPLAY_PRODUCTS_LISTING/PRODUCT_LISTING_COLUMNS_PER_ROW)) : MAX_DISPLAY_PRODUCTS_LISTING;
$show_submit = zen_run_normal();
$listing_split = new splitPageResults($listing_sql, $max_results, 'p.products_id', 'page');
$how_many = 0;
// Begin Row Layout Header
if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows') {		// For Column Layout (Grid Layout) add on module
  $list_box_contents[0] = array('params' => 'class="productListing-rowheading"');
  $zc_col_count_description = 0;
  $lc_align = '';
  for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
    switch ($column_list[$col]) {
      case 'PRODUCT_LIST_MODEL':
        $lc_text = TABLE_HEADING_MODEL;
        $lc_align = '';
        $zc_col_count_description++;
        break;
      case 'PRODUCT_LIST_NAME':
        $lc_text = TABLE_HEADING_PRODUCTS;
        $lc_align = '';
        $zc_col_count_description++;
        break;
      case 'PRODUCT_LIST_MANUFACTURER':
        $lc_text = TABLE_HEADING_MANUFACTURER;
        $lc_align = '';
        $zc_col_count_description++;
        break;
      case 'PRODUCT_LIST_PRICE':
        $lc_text = TABLE_HEADING_PRICE;
        $lc_align = 'right' . (PRODUCTS_LIST_PRICE_WIDTH > 0 ? '" width="' . PRODUCTS_LIST_PRICE_WIDTH : '');
        $zc_col_count_description++;
        break;
      case 'PRODUCT_LIST_QUANTITY':
        $lc_text = TABLE_HEADING_QUANTITY;
        $lc_align = 'right';
        $zc_col_count_description++;
        break;
      case 'PRODUCT_LIST_WEIGHT':
        $lc_text = TABLE_HEADING_WEIGHT;
        $lc_align = 'right';
        $zc_col_count_description++;
        break;
      case 'PRODUCT_LIST_IMAGE':
        $lc_text = TABLE_HEADING_IMAGE;
        $lc_align = 'center';
        $zc_col_count_description++;
        break;
    }
    if ( ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
      $lc_text = zen_create_sort_heading($_GET['sort'], $col+1, $lc_text);
    }
    $list_box_contents[0][$col] = array('align' => $lc_align,
                                        'params' => 'class="productListing-heading"',
                                        'text' => $lc_text );
  }
} // End Row Layout Header used in Column Layout (Grid Layout) add on module
/////////////  HEADER ROW ABOVE /////////////////////////////////////////////////
$num_products_count = $listing_split->number_of_rows;
if ($listing_split->number_of_rows > 0) {
  $rows = 0;
  // Used for Column Layout (Grid Layout) add on module
  $column = 0;	
  if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns') {
    if ($num_products_count < PRODUCT_LISTING_COLUMNS_PER_ROW || PRODUCT_LISTING_COLUMNS_PER_ROW == 0 ) {
      $col_width = floor(100/$num_products_count) - 0.5;
    } else {
      $col_width = floor(100/PRODUCT_LISTING_COLUMNS_PER_ROW) - 0.5;
    }
  }
  // Used for Column Layout (Grid Layout) add on module
  $listing = $db->Execute($listing_split->sql_query);
  $extra_row = 0;
  while (!$listing->EOF) {
    if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows') { // Used in Column Layout (Grid Layout) Add on module
      $rows++;
      if ((($rows-$extra_row)/2) == floor(($rows-$extra_row)/2)) {
        $list_box_contents[$rows] = array('params' => 'class="productListing-even"');
      } else {
        $list_box_contents[$rows] = array('params' => 'class="productListing-odd"');
      }
      $cur_row = sizeof($list_box_contents) - 1;
    }   // End of Conditional execution - only for row (regular style layout)
    $product_contents = array(); // Used For Column Layout (Grid Layout) Add on module
    for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
      $lc_align = '';
      switch ($column_list[$col]) {
        case 'PRODUCT_LIST_MODEL':
          $lc_model = $listing->fields['products_model'] .
 ( zen_products_lookup($listing->fields['products_id'], 'products_viewed') > 0 ? '<li>' . 'Views: ' . zen_products_lookup($listing->fields['products_id'], 'products_viewed') . '</li>' : '') . '<br />';
          $lc_align = '';
          $lc_text = $lc_model;
          break;
        case 'PRODUCT_LIST_NAME':
          $lc_align = '';
          if (isset($_GET['manufacturers_id'])) {
            $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' ;
          } else {
            $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
          }
          break;
        case 'PRODUCT_LIST_MANUFACTURER':
          $lc_align = '';
          $lc_text = '<a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']) . '">' . $listing->fields['manufacturers_name'] . '</a>';
          break;
        case 'PRODUCT_LIST_PRICE':
          $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
          $lc_align = 'right';
          $lc_text =  $lc_price;
          // more info in place of buy now
          $lc_button = '';
          if (zen_has_product_attributes($listing->fields['products_id']) or PRODUCT_LIST_PRICE_BUY_NOW == '0') {
            $lc_button = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
          } else {
            if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0) {
            if (
                // not a hide qty box product
                $listing->fields['products_qty_box_status'] != 0 &&
                // product type can be added to cart
                zen_get_products_allow_add_to_cart($listing->fields['products_id']) != 'N'
                &&
                // product is not call for price
                $listing->fields['product_is_call'] == 0
                &&
                // product is in stock or customers may add it to cart anyway
                ($listing->fields['products_quantity'] > 0 || SHOW_PRODUCTS_SOLD_OUT_IMAGE == 0) ) {
                    $how_many++;
                  }
            // hide quantity box
            if ($listing->fields['products_qty_box_status'] == 0) {
              $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</a>';
            } else {
              $lc_button = TEXT_PRODUCT_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $listing->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
            }
          } else {
// qty box with add to cart button
            if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
              $lc_button= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($listing->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing->fields['products_id']), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';
            } else {
              $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</a>';
            }
            }
          }
          $the_button = $lc_button;
        $products_link = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
          $lc_text .= '<br />' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($listing->fields['products_id']);
          $lc_text .= '<br />' . (zen_get_show_product_switch($listing->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($listing->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');
          break;
        case 'PRODUCT_LIST_QUANTITY':
          $lc_align = 'right';
          $lc_text = $listing->fields['products_quantity'];
          break;
        case 'PRODUCT_LIST_WEIGHT':
          $lc_align = 'right';
          $lc_text = $listing->fields['products_weight'];
          break;
        case 'PRODUCT_LIST_IMAGE':
          $lc_align = 'center';
        if ($listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
          $lc_text = '';
        } else {
          if (isset($_GET['manufacturers_id'])) {
          $lc_text = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage"') . '</a>';
          } else {
          $lc_text = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage"') . '</a>';
          }
        }
          break;
      }
      $product_contents[] = $lc_text; // Used For Column Layout (Grid Layout) Option
      if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows') {
        $list_box_contents[$rows][$col] = array('align' => $lc_align,
                                                'params' => 'class="productListing-data"',
                                                'text'  => $lc_text);
      }
    }
    // add description and match alternating colors
    //if (PRODUCT_LIST_DESCRIPTION > 0) {
    //  $rows++;
    //  if ($extra_row == 1) {
    //    $list_box_description = "productListing-data-description-even";
    //    $extra_row=0;
    //  } else {
    //    $list_box_description = "productListing-data-description-odd";
    //    $extra_row=1;
    //  }
    //  $list_box_contents[$rows][] = array('params' => 'class="' . $list_box_description . '" colspan="' . $zc_col_count_description . '"',
    //  'text' => zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION));
    //}
    // Following code will be executed only if Column Layout (Grid Layout) option is chosen
    if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns') {
      $lc_text = implode('<br />', $product_contents);
      $list_box_contents[$rows][$column] = array('params' => 'class="centerBoxContentsProducts centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
                                                 'text'  => $lc_text);
      $column ++;
      if ($column >= PRODUCT_LISTING_COLUMNS_PER_ROW) {
        $column = 0;
        $rows ++;
      }
    }
    // End of Code fragment for Column Layout (Grid Layout) option in add on module
    $listing->MoveNext();
  }
  $error_categories = false;
} else {
  $list_box_contents = array();
  $list_box_contents[0] = array('params' => 'class="productListing-odd"');
  $list_box_contents[0][] = array('params' => 'class="productListing-data"',
                                  'text' => TEXT_NO_PRODUCTS);
  $error_categories = true;
}
if (($how_many > 0 and $show_submit == true and $listing_split->number_of_rows > 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 1 or  PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 3) ) {
  $show_top_submit_button = true;
} else {
  $show_top_submit_button = false;
}
if (($how_many > 0 and $show_submit == true and $listing_split->number_of_rows > 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART >= 2) ) {
  $show_bottom_submit_button = true;
} else {
  $show_bottom_submit_button = false;
}
  if ($how_many > 0 && PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == true and $listing_split->number_of_rows > 0) {
  // bof: multiple products
    echo zen_draw_form('multiple_products_cart_quantity', zen_href_link(FILENAME_DEFAULT, zen_get_all_get_params(array('action')) . 'action=multiple_products_add_product'), 'post', 'enctype="multipart/form-data"');
  }
?>

The code in red color was just revised. Please what is causing the problem? Thanks.

17 Apr 2015, 5:27 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Displaying Product Viewed in Product Listing Page

I have mine on the price case:

        case 'PRODUCT_LIST_PRICE':

Did you mean to add that to the model case?

        case 'PRODUCT_LIST_MODEL':
17 Apr 2015, 6:22 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Displaying Product Viewed in Product Listing Page

NOTE: if you do want it under the:

        case 'PRODUCT_LIST_MODEL':
        $lc_align = '';
        $lc_text = $listing->fields['products_model'];

You cannot make up variables and would use:

        case 'PRODUCT_LIST_MODEL':
        $lc_align = '';
[B]//[/B]        $lc_text = $listing->fields['products_model'];
[B]        $lc_text = $listing->fields['products_model'] .
 ( zen_products_lookup($listing->fields['products_id'], 'products_viewed') > 0 ? '<li>' . 'Views: ' . zen_products_lookup($listing->fields['products_id'], 'products_viewed') . '</li>' : '') . '<br />';
[/B]        break;
18 Apr 2015, 3:30 AM
#8
eric_chen avatar

eric_chen

New Zenner

Join Date:
May 2012
Posts:
39
Plugin Contributions:
0

Re: Displaying Product Viewed in Product Listing Page

Yes, I'd like to show view count report after model number.

Ajeh:

I have mine on the price case:

    case 'PRODUCT_LIST_PRICE':
> 
> Did you mean to add that to the model case?
> ```
        case 'PRODUCT_LIST_MODEL':
18 Apr 2015, 3:42 AM
#9
eric_chen avatar

eric_chen

New Zenner

Join Date:
May 2012
Posts:
39
Plugin Contributions:
0

Re: Displaying Product Viewed in Product Listing Page

I just copied and replaced above code (model case) exactly in my products_listing.php, but regret that it doesn't make any different result as revising it on the price case. Each product still shows same viewed count report which is exactly from the first product (products_id with 1) in my store. The problem seems too much complicated...~~ Thank you!!!

18 Apr 2015, 1:12 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Displaying Product Viewed in Product Listing Page

When I use this:

        case 'PRODUCT_LIST_MODEL':
        $lc_align = '';
[B]//[/B]        $lc_text = $listing->fields['products_model'];
[B]        $lc_text = $listing->fields['products_model'] .
 ( zen_products_lookup($listing->fields['products_id'], 'products_viewed') > 0 ? '<li>' . 'Views: ' . zen_products_lookup($listing->fields['products_id'], 'products_viewed') . '</li>' : '') . '<br />';
[/B]        break;

It works fine for me and I get the proper results ...

As a test, let's see what products_id is being used by using this:

        case 'PRODUCT_LIST_MODEL':
        $lc_align = '';
[B]//[/B]        $lc_text = $listing->fields['products_model'];
[B]        $lc_text = $listing->fields['products_model'] .
 ( zen_products_lookup($listing->fields['products_id'], 'products_viewed') > 0 ? '<li>' . 'Views: ' . zen_products_lookup($listing->fields['products_id'], 'products_viewed') . '</li>' : '') . ' - ' . $listing->fields['products_id'] . '<br />';
[/B]        break;

What this will do is add next to the products_viewed a:

  • products_id ##

To show the products_id that is being used ...

18 Apr 2015, 1:59 PM
#11
eric_chen avatar

eric_chen

New Zenner

Join Date:
May 2012
Posts:
39
Plugin Contributions:
0

Re: Displaying Product Viewed in Product Listing Page

:cool: Great!!! It outputs correct "products_id". I just did a test by the above code, and got correct "products_id" but still same view report. So now the problem focuses on why the ID number is correct, but could not output the correct view report related with the "products_id"??? I took a screen shot from my store for reference as following:

Attachment #15192

18 Apr 2015, 2:05 PM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Displaying Product Viewed in Product Listing Page

And if you look, via phpMyAdmin, at the table:
products

for those products_id what are their values in the field products_viewed?

Sounds dumb but let's make sure they are not all set to 8 ... :lookaroun

18 Apr 2015, 2:48 PM
#13
eric_chen avatar

eric_chen

New Zenner

Join Date:
May 2012
Posts:
39
Plugin Contributions:
0

Re: Displaying Product Viewed in Product Listing Page

According to the instructions, I checked "products" table via phpMyAdmin,
and strangely don't see the field products_viewed but exceptionally found it on the table "products_description".

Should the code look up products_viewed from the table "products_description", instead of the table "products"?

18 Apr 2015, 2:49 PM
#14
eric_chen avatar

eric_chen

New Zenner

Join Date:
May 2012
Posts:
39
Plugin Contributions:
0

Re: Displaying Product Viewed in Product Listing Page

According to the instructions, I checked "products" table via phpMyAdmin,

and strangely don't see the field products_viewed but exceptionally found it on the table "products_description".

Should the code look up products_viewed from the table "products_description", instead of the table "products"?

18 Apr 2015, 3:00 PM
#15
eric_chen avatar

eric_chen

New Zenner

Join Date:
May 2012
Posts:
39
Plugin Contributions:
0

Re: Displaying Product Viewed in Product Listing Page

The following are the details of the two tables in my store:

Products table (screen shot):
Attachment #15193

Products_description table (screen shot):
Attachment #15194

18 Apr 2015, 3:14 PM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Displaying Product Viewed in Product Listing Page

My bad ... I should have said look in the table:
products_description

for the field:
products_viewed

When you look up those products_id what do you find set on the products_viewed?

18 Apr 2015, 3:22 PM
#17
eric_chen avatar

eric_chen

New Zenner

Join Date:
May 2012
Posts:
39
Plugin Contributions:
0

Re: Displaying Product Viewed in Product Listing Page

I see some of numbers on the field of products_viewed:

.... (products_viewed) VALUES
(71, 0),
(64, 1),
(27, 2),
(19, 3),
(3, 4),
(3, 5),
(1, 6),
(1, 7),
(1, 8),
(1, 9);

But I don't understand what it means... Please is the problem from here? Thanks.

18 Apr 2015, 3:27 PM
#18
eric_chen avatar

eric_chen

New Zenner

Join Date:
May 2012
Posts:
39
Plugin Contributions:
0

Re: Displaying Product Viewed in Product Listing Page

Never mind! So up to now, is there any possibility to look up correct products viewed report by suitable code on products listing page?

18 Apr 2015, 3:44 PM
#19
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Displaying Product Viewed in Product Listing Page

In your Zen Cart Admin if you go to Reports ... Products Viewed ... you will see a list of all of your Products and what their products_viewed field is, it shows the products_id products_name products_viewed ...

So you can check what those particular products_id have set for the number of views on the Products ...

Are they all set to 8 or do they have different values than what is displayed on picture of the 4 Products?

You showed it for products_id:
187
162
10
158

What do you see on that Products Viewed report in your admin for those products_id values?

18 Apr 2015, 4:00 PM
#20
eric_chen avatar

eric_chen

New Zenner

Join Date:
May 2012
Posts:
39
Plugin Contributions:
0

Re: Displaying Product Viewed in Product Listing Page

Sorry for the misunderstanding. ~~ I don't mean only the four products with ID 187,162,10,158, but also whole products on product listing of each category, showing same viewed report. It is just an example for the four products that is the first row under a category in my store, which I took the screen shot for your reference.