Forums / Bug Reports / [Done 1.3.6] products_new limt (1.3.5)

[Done 1.3.6] products_new limt (1.3.5)

Locked

Started by paulm on 22 Sep 2006, 12:58 PM · Views: 4,653

Results 1 to 20 of 24
This thread is locked. New replies are disabled.
22 Sep 2006, 12:58 PM
#1
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

[Done 1.3.6] products_new limt (1.3.5)

Zen Cart 1.3.5

I found a problem with the products_new time limit.

There is an admin setting "New Product Listing - Limited to" (under max values). And I think this is meant to limit the products_new output.

But it does not seem to work, and if I look in the header_php.php file for the products_new page it shows:

  //$display_limit = zen_get_products_new_timelimit();
  $display_limit = zen_get_new_date_range();

So it looks like is was changed to use zen_get_new_date_range() (or that someone was preparing to make it use zen_get_products_new_timelimit()).

A look at zen_get_new_date_range() shows:

// build date range for new products
  function zen_get_new_date_range($time_limit = false) {
    if ($time_limit == false) {
      $time_limit = SHOW_NEW_PRODUCTS_LIMIT;
    }

    // 120 days; 24 hours; 60 mins; 60secs
    $date_range = time() - ($time_limit * 24 * 60 * 60);
// echo 'Now:      '. date('Y-m-d') ."<br />";
// echo $time_limit . ' Days: '. date('Ymd', $date_range) ."<br />";
    $zc_new_date = date('Ymd', $date_range);
    $new_range = ' and p.products_date_added >=' . $zc_new_date;
    return "";
    return $new_range;
  }

This confirms that the formentioned admin setting indeed is meant to set the limit:

      $time_limit = SHOW_NEW_PRODUCTS_LIMIT;

But just before the actual value is returned another return is executed:

    return "";

Which causes the function to return an empty string of course (and products_new shows all products).

I am not sure what the intention was, but if I comment out the return, or if I change header_php.php to use zen_get_products_new_timelimit(), it is possible to set the products_new time range again from admin.

22 Sep 2006, 1:05 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: [Done 1.3.6] products_new limt (1.3.5)

Looks like you missed updating a file ...

Look at the fixes in:
http://www.zen-cart.com/forum/showthread.php?t=45377

There is one for that function too ... be careful not to delete the function below it ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

22 Sep 2006, 1:27 PM
#3
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: [Done 1.3.6] products_new limt (1.3.5)

Ok, thanks Ajeh!

I searched that thread for products_new ..... so I did not find it. The shop indeed is a stock 1.3.5 shop.

I was triyng to figure something out about 1.2.7 for someone, and never expected to bump into a 1.3.5 bug while doing that :blink:

Seems strange though that zen_get_products_new_timelimit is not being used, that function seems to do exactly the same, after a small modification.

22 Sep 2006, 1:29 PM
#4
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: [Done 1.3.6] products_new limt (1.3.5)

I can not edit my posts anymore B.T.W., but I suppose that is just me? (when I click edit nothing happens)

edit: when I copy and paste the edit url, it works though :wacko:

22 Sep 2006, 1:33 PM
#5
ajeh avatar

ajeh

Oba-san

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

Re: [Done 1.3.6] products_new limt (1.3.5)

The "same" vs speed is two different things ...

The new function utilizes a different method of "date math" to pass through a data base of 1000s of records in .05 to .5 seconds vs 45-200 seconds ...

Use the new function with the fix ... :cool:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

22 Sep 2006, 1:50 PM
#6
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: [Done 1.3.6] products_new limt (1.3.5)

Nice speed improvement indeed :thumbsup:

It seems more logical that the zen_get_new_date_range() would have been replaced by the current zen_get_products_new_timelimit() code then. But I assume that is related to some compatibility issue.

But thanks for the explanation, I certainly overlooked the speed issue.

26 Oct 2006, 5:36 PM
#7
jeffmic avatar

jeffmic

Zen Follower

Join Date:
Aug 2006
Location:
North Carolina
Posts:
280
Plugin Contributions:
0

Re: [Done 1.3.6] products_new limt (1.3.5)

I have pasted in the fix to New Products into my
/includes/functions/functions_lookups.php

All I'm getting it this in my browser...

Parse error: parse error in /Volumes/Files/MCzenstore/includes/functions/functions_lookups.php on line 802

I have been very careful not to change anything else, but it's not working for me.

Can you verify any other problem going on here?

thanks

Jeff Michaels

Jeff Michaels,
pres of Musical Creations Ltd.

26 Oct 2006, 6:05 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: [Done 1.3.6] products_new limt (1.3.5)

More than likely you copied the code incorrectly ...

Start with a clean
/includes/functions/functions_lookup.php

This is the complete bottom of the file:

////
// get define of New Products
  function zen_get_products_new_timelimit($time_limit = false) {
    if ($time_limit == false) {
      $time_limit = SHOW_NEW_PRODUCTS_LIMIT;
    }
    switch (true) {
      case ($time_limit == '0'):
        $display_limit = '';
        break;
      case ($time_limit == '1'):
        $display_limit = " and date_format(p.products_date_added, '%Y%m') >= date_format(now(), '%Y%m')";
        break;
      case ($time_limit == '7'):
        $display_limit = ' and TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) <= 7';
        break;
      case ($time_limit == '14'):
        $display_limit = ' and TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) <= 14';
        break;
      case ($time_limit == '30'):
        $display_limit = ' and TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) <= 30';
        break;
      case ($time_limit == '60'):
        $display_limit = ' and TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) <= 60';
        break;
      case ($time_limit == '90'):
        $display_limit = ' and TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) <= 90';
        break;
      case ($time_limit == '120'):
        $display_limit = ' and TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) <= 120';
        break;
    }
    return $display_limit;
  }

////
// check if Product is set to use downloads
// does not validate download filename
  function zen_has_product_attributes_downloads_status($products_id) {
    global $db;
    if (DOWNLOAD_ENABLED == 'true') {
      $download_display_query_raw ="select pa.products_attributes_id, pad.products_attributes_filename
                                    from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                                    where pa.products_id='" . (int)$products_id . "'
                                      and pad.products_attributes_id= pa.products_attributes_id";

      $download_display = $db->Execute($download_display_query_raw);
      if ($download_display->RecordCount() != 0) {
        $valid_downloads = false;
      } else {
        $valid_downloads = true;
      }
    } else {
      $valid_downloads = false;
    }
    return $valid_downloads;
  }

// build date range for new products
  function zen_get_new_date_range($time_limit = false) {
    if ($time_limit == false) {
      $time_limit = SHOW_NEW_PRODUCTS_LIMIT;
    }
    // 120 days; 24 hours; 60 mins; 60secs
    $date_range = time() - ($time_limit * 24 * 60 * 60);
    $upcoming_mask_range = time();
    $upcoming_mask = date('Ymd', $upcoming_mask_range);

// echo 'Now:      '. date('Y-m-d') ."<br />";
// echo $time_limit . ' Days: '. date('Ymd', $date_range) ."<br />";
    $zc_new_date = date('Ymd', $date_range);
    switch (true) {
    case (SHOW_NEW_PRODUCTS_LIMIT == 0):
      $new_range = '';
      break;
    case (SHOW_NEW_PRODUCTS_LIMIT == 1):
      $zc_new_date = date('Ym', time()) . '01';
      $new_range = ' and p.products_date_added >=' . $zc_new_date;
      break;
    default:
      $new_range = ' and p.products_date_added >=' . $zc_new_date;
    }

    if (SHOW_NEW_PRODUCTS_UPCOMING_MASKED == 0) {
      // do nothing upcoming shows in new
    } else {
      // do not include upcoming in new
      $new_range .= " and (p.products_date_available <=" . $upcoming_mask . " or p.products_date_available IS NULL)";
    }
    return $new_range;
  }


// build date range for upcoming products
  function zen_get_upcoming_date_range() {
    // 120 days; 24 hours; 60 mins; 60secs
    $date_range = time();
// echo 'Now:      '. date('Y-m-d') ."<br />";
// echo 'Upcoming Days: '. date('Ymd', $date_range) ."<br />";
    $zc_new_date = date('Ymd', $date_range);
    $new_range = ' and p.products_date_available >=' . $zc_new_date;
//    $new_range = ' and ' . EXPECTED_PRODUCTS_FIELD . ' <=' . $zc_new_date;

    return $new_range;
  }

?>

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

26 Oct 2006, 6:23 PM
#9
jeffmic avatar

jeffmic

Zen Follower

Join Date:
Aug 2006
Location:
North Carolina
Posts:
280
Plugin Contributions:
0

Re: [Done 1.3.6] products_new limt (1.3.5)

I just copied over a fresh version of the file and now I'm getting this error when inserting your latest code.

I'm replacing only exactly what is needed and no more ?!?

Parse error: parse error in /Volumes/Files/MCzenstore/includes/functions/functions_lookups.php on line 747

what else would be associated with this problem?

thanks so much,

(coffee's coming)

Jeff

Jeff Michaels,
pres of Musical Creations Ltd.

26 Oct 2006, 6:25 PM
#10
jeffmic avatar

jeffmic

Zen Follower

Join Date:
Aug 2006
Location:
North Carolina
Posts:
280
Plugin Contributions:
0

Re: [Done 1.3.6] products_new limt (1.3.5)

nothing else in the entire function folder has ever been modified either

Jeff Michaels,
pres of Musical Creations Ltd.

26 Oct 2006, 9:15 PM
#11
jeffmic avatar

jeffmic

Zen Follower

Join Date:
Aug 2006
Location:
North Carolina
Posts:
280
Plugin Contributions:
0

Re: [Done 1.3.6] products_new limt (1.3.5)

Is there any luck at find a solution to this problem?

Just a note: My product dates are all set to July 1, 2006 and the time is midnight (all zeros). I cannot apply the bug fix without the parse error mentioned above.
I've also been PM'd by another user (keystonewebworks) with the same problem. I've tried all the options for dates in the config too. If it makes a difference, I have over 23,000 products.
I just downloaded a new install and took the file from it's folder and it does the same thing with the patch. It does the same exact thing with the classic template.

I just can't get this to work at all without all the products appearing or applying the patch and it causing the site to stop working.

I contacted the company that I bought the template from and they have nothing to do with causing this error...

see below:

<<Sorry for the delay in the response. The two items you posted to us are not
template related issues. These are issues that are in the inherent in the cart
itself. To fix them you will need to modify the zencart files yourself. You
may want to look at the
includes/modules/pages/advanced_search_result/header.php and
includes/modules/pages/products_new/header.php files as they contain the code
that builds the SQL commands to display the products on the page.

Regards,
Algozone Support Team>>

thanks,
Jeff

Jeff Michaels,
pres of Musical Creations Ltd.

26 Oct 2006, 11:34 PM
#12
ajeh avatar

ajeh

Oba-san

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

Re: [Done 1.3.6] products_new limt (1.3.5)

There are two functions at the bottom of the functions_lookups.php

You are technically replacing the 2nd to the last one ...

But if you are confused ... that post above contains everything from the function you need to replace all the way to the end of the file and that post I made includes the closing php tag for the ?>

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

27 Oct 2006, 1:20 AM
#13
jeffmic avatar

jeffmic

Zen Follower

Join Date:
Aug 2006
Location:
North Carolina
Posts:
280
Plugin Contributions:
0

Re: [Done 1.3.6] products_new limt (1.3.5)

I'm sorry Linda, I did EXACTLY as you said and it gives the parse error above.

Jeff Michaels,
pres of Musical Creations Ltd.

27 Oct 2006, 1:21 AM
#14
ajeh avatar

ajeh

Oba-san

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

Re: [Done 1.3.6] products_new limt (1.3.5)

sigh :cry:

Drop me a PM with your email address please ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

27 Oct 2006, 1:23 AM
#15
jeffmic avatar

jeffmic

Zen Follower

Join Date:
Aug 2006
Location:
North Carolina
Posts:
280
Plugin Contributions:
0

Re: [Done 1.3.6] products_new limt (1.3.5)

hmmm.

How do you send a PM in this forum??

(sorry)

Jeff

Jeff Michaels,
pres of Musical Creations Ltd.

27 Oct 2006, 1:34 AM
#16
ajeh avatar

ajeh

Oba-san

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

Re: [Done 1.3.6] products_new limt (1.3.5)

I dropped you a copy of the fixed function file ... let us know how it works for you ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

27 Oct 2006, 1:37 AM
#17
jeffmic avatar

jeffmic

Zen Follower

Join Date:
Aug 2006
Location:
North Carolina
Posts:
280
Plugin Contributions:
0

Re: [Done 1.3.6] products_new limt (1.3.5)

this is pretty sad huh?

it's not working

Fatal error: Cannot redeclare zen_get_products_new_timelimit() (previously declared in /Volumes/Files/MCzenstore/includes/functions/functions_lookups.php:792) in /Volumes/Files/MCzenstore/includes/functions/functions_lookups.php on line 850

Jeff Michaels,
pres of Musical Creations Ltd.

27 Oct 2006, 1:45 AM
#18
ajeh avatar

ajeh

Oba-san

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

Re: [Done 1.3.6] products_new limt (1.3.5)

You renamed your old file:
/includes/functions/functions_lookups.php

/includes/functions/functions_lookups.php.OLD_BROKEN_FILE

And loaded the new file that I sent to you for functions_lookups.php

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

27 Oct 2006, 1:48 AM
#19
jeffmic avatar

jeffmic

Zen Follower

Join Date:
Aug 2006
Location:
North Carolina
Posts:
280
Plugin Contributions:
0

Re: [Done 1.3.6] products_new limt (1.3.5)

I only replaced the old one with the one you sent me.

Jeff Michaels,
pres of Musical Creations Ltd.

27 Oct 2006, 1:50 AM
#20
ajeh avatar

ajeh

Oba-san

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

Re: [Done 1.3.6] products_new limt (1.3.5)

1st rename or delete the existing file on the server ...

2nd upload the new file ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!