Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2008
    Location
    Rimini, Italy, Italy
    Posts
    67
    Plugin Contributions
    0

    Default Duplicated "new products" when they're less than 9

    Hi everybody,
    my shop's showing 9 new products (i think that's the default setting).
    In some categories when I have only 1 (or any number of new products less then 9) new product, New Products Listing shows 2 or more copies of this product. I was looking for a solution browsing php code but I cannot find it (not yet, anyway).

    Please, there's someone with same problem? any solutions out there?

  2. #2
    Join Date
    Dec 2008
    Location
    Rimini, Italy, Italy
    Posts
    67
    Plugin Contributions
    0

    Default [SOLVED] Re: Duplicated "new products" when they're less than 9

    I had same problem in both new and special products.
    Here's a simple hack to solve it.

    Fisrt copy new_products.php and specials_index.php from /includes/modules to /includes/modules/CUSTOM_TEMPLATE

    (where CUSTOM_TEMPLATE is your current template name)

    In both files find $row and $col variable initialization:

    PHP Code:
    $row 0;
    $col 0
    add following line:

    PHP Code:
    $mycounter 
    Next, find $col variable increment:

    PHP Code:
        $col ++; 
    add following line:

    PHP Code:
        $mycounter ++; 

    Next in specials_index.php file, find:

    PHP Code:
    while (!$specials_index->EOF)  { 
    and change it to:

    PHP Code:
    while ( (!$specials_index->EOF) && ($mycounter $num_products_count) ) { 
    Next in new_products.php file, find:

    PHP Code:
    while (!$new_products->EOF)  { 
    and change it to:

    PHP Code:
    while ((!$new_products->EOF) && ($mycounter $num_products_count)) { 
    That's all folks... (you may want to apply similar hacks to featured products box also...I'm pretty sure you have to modify featured_products.php the very same way)

  3. #3
    Join Date
    Dec 2008
    Location
    Rimini, Italy, Italy
    Posts
    67
    Plugin Contributions
    0

    Default Re: [SOLVED] Re: Duplicated "new products" when they're less than 9

    NEW ALTERNATIVE HACK: just another solution for same problem

    Tonite I was not sleeping as I should....so I spent a little bit of my time playing with another solution to this problem).

    I don't know if it's less or more heavy to compute....for sure it allows you to modify just one line of involved files without declaring or using new variables:

    Fisrt, copy new_products.php and specials_index.php from /includes/modules to /includes/modules/CUSTOM_TEMPLATE

    (where CUSTOM_TEMPLATE is your current template name)

    In specials_index.php file, find:

    PHP Code:
    while (!$specials_index->EOF)  { 
    and change it to:

    PHP Code:
    while ( (!$specials_index->EOF) && (((($row $col) + ((SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS $col) * ($row 1))) + SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS) < $num_products_count) ) { 
    Next in new_products.php file, find:

    PHP Code:
    while (!$new_products->EOF)  { 
    and change it to:

    PHP Code:
    while ((!$new_products->EOF) && (((($row $col) + ((SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS $col) * ($row 1))) + SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS) < $num_products_count) ) { 
    That's all folks... (you may want to apply similar hacks to featured products box also...I'm pretty sure you have to modify featured_products.php the very same way)[/QUOTE]

    SOME EXPLANATIONS

    Every matrix element can be represented by row and column values.

    Its numerical order in the matrix can be computed ad follows:

    Code:
    (R * C) + ((MAXC - C) * (R - 1))
    Where:

    Code:
         R is the row
         C is the column
         MAXC is the number of columns in our matrix
    In my hack:

    Code:
         R is $row variable
         C is $col variable
         MAXC is SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS and SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS constants
    In ZC matrix first row and column have a value of zero, so I had to slightly modify the formula to:
    Code:
    ((R * C) + ((MAXC - C) * (R - 1))) + MAXC

  4. #4
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Duplicated "new products" when they're less than 9

    Quote Originally Posted by moosesoom View Post
    Hi everybody,
    my shop's showing 9 new products (i think that's the default setting).
    In some categories when I have only 1 (or any number of new products less then 9) new product, New Products Listing shows 2 or more copies of this product. I was looking for a solution browsing php code but I cannot find it (not yet, anyway).
    That's not normal behavior. You've likely got damaged data or damaged code causing the abnormal duplication.
    I don't see any such duplication on a clean fresh new install, using demo data or adding my own products.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Dec 2008
    Location
    Rimini, Italy, Italy
    Posts
    67
    Plugin Contributions
    0

    Default Re: Duplicated "new products" when they're less than 9

    Thanks Dr.
    The only thing (apparently) changed in news/specials products was the hack to obtain real randomness taken from http://www.zen-cart.com/forum/showth...t=70543&page=3 thread

    Tomorrow I'll try the hack on a virgin test shop just to be sure....

  6. #6
    Join Date
    Dec 2008
    Location
    Rimini, Italy, Italy
    Posts
    67
    Plugin Contributions
    0

    Default Re: Duplicated "new products" when they're less than 9

    Quote Originally Posted by DrByte View Post
    That's not normal behavior. You've likely got damaged data or damaged code causing the abnormal duplication.
    Just finished some tests.
    It turned to be a consequence of the "random hack" I talked about in my previous post.

 

 

Similar Threads

  1. v151 "Display Cart After Adding Product" - Only if Stock is Less than 1
    By gaffettape in forum General Questions
    Replies: 3
    Last Post: 6 Jan 2013, 08:40 PM
  2. Replies: 4
    Last Post: 16 Oct 2011, 12:58 AM
  3. What does the public see when they click "new products"
    By sofasurfer in forum General Questions
    Replies: 3
    Last Post: 12 Jul 2011, 08:20 AM
  4. How to remove ellipses ("...") after "All Products" and "New Products" on home page?
    By jthurman in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 18 May 2010, 03:30 PM
  5. Replies: 1
    Last Post: 28 Jul 2009, 12:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg