Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

products_new showing *all* products


Guest

Recommended Posts

Isn't the whole point of products_new.php to display only the new products? Why should we have to mark the new products on that page? Shouldn't the page only display products that are new?

 

I did get it to only display the items that are new w/in the last 30 days, but it's just a display thing. The results query still returns all of the products. This means that it'll still say "Displaying 1-20 (of 5000 new products)" if you have 5000 products in your store.

 

We need to fix it before displaying, not while displaying. We can't really change the query, since we don't know the value of products_date_added before the query happens.

 

Someone else want to lend a hand here?

 

-jared

Link to comment
Share on other sites

No, I do want the new products page to loop all products as I do not have much items in my store actually and new products page is a good place that my customers can find all my items in all categories!

 

and I've finished to add the icon in the index page. But not very understand what is the meaning of looping in the previous forum?

Link to comment
Share on other sites

No, I do want the new products page to loop all products as I do not have much items in my store actually and new products page is a good place that my customers can find all my items in all categories!

 

and I've finished to add the icon in the index page. But not very understand what is the meaning of looping in the previous forum?

 

Can someone tell me how to display more than 9 products on the new products window. I only have 20 products and want to show them all. Please help

Link to comment
Share on other sites

Can someone tell me how to display more than 9 products on the new products window.  I only have 20 products and want to show them all.  Please help

 

In your admin center go to maximum values-> new proucts module-> set to 20

The Knowledge Base is a wonderful thing.

Do you have a problem? Have you checked out Common Problems?

There are many very useful osC Contributions

Are you having trouble with a installed contribution? Have you checked out the support thread found Here

BACKUP BACKUP BACKUP!!! You did backup, right??

Link to comment
Share on other sites

  • 2 weeks later...
. . . new products page is a good place that my customers can find all my items in all categories!

 

That is what you have an "all products" page for. You're using the "new products" for an unintended use.

 

-jared

Link to comment
Share on other sites

That is what you have an "all products" page for.  You're using the "new products" for an unintended use.

 

-jared

Reading this topic I wonder why products_new.php does not have a checkbox in front of the Add To Cart button.

 

Anybody did this already?

"If you're working on something new, then you are necessarily an amateur."

Link to comment
Share on other sites

I don't think checkboxes are there by default on any of the category/product pages, either. A contrib that adds this should be easy to adapt to the new products page, though.

 

-jared

Link to comment
Share on other sites

I was having a look at this thread here about restricting the new products being shown to those added after a certain date. Doug's added new fields to the configuration table to enable him to set certain dates, but if you don't want to have to alter the dates/values all the time, that doesn't work so well.

 

Then afterward Larry came up with a global variable of sorts which he added to his query to make it only display the products added after the 1st of each month. Fair enough if you add new products on the same day each month, but what if products are added sporadically (or when the boss says "Do it now!")?

Products added toward the end of a month wouldn't be shown after the 1st comes around.

 

In the other thread of yours (regarding adding icons to the new products) you've given the 30 day value in the unix timestamp format.

 

Is it possible to somehow combine all of these ideas into one little piece of code?

As in your previous one you set $today_time = time(); at the top.

 

Can you then subtract the 30 day unix timestamp (2592000) from the $today_time variable, and then turn that into datetime format, to get the date that was 30 days previous?

 

So perhaps having something along the lines of:

$new_product_cutoff = ($today_time - 2592000);

turn $new_product_cutoff into a datetime variable;

// therefore turning it into something like 2004-11-06 (which is 30 days back from today)

 

then having a "where p.product_date_added >= $new_product_cutoff" clause in the product_new_query_raw select statement

 

so that the new product listings will only show products added after the cutoff date?

 

.. did that make any sense to you?

 

Isn't the whole point of products_new.php to display only the new products? Why should we have to mark the new products on that page? Shouldn't the page only display products that are new?

 

I did get it to only display the items that are new w/in the last 30 days, but it's just a display thing. The results query still returns all of the products. This means that it'll still say "Displaying 1-20 (of 5000 new products)" if you have 5000 products in your store.

 

We need to fix it before displaying, not while displaying. We can't really change the query, since we don't know the value of products_date_added before the query happens.

 

Someone else want to lend a hand here?

 

-jared

Link to comment
Share on other sites

I believe this modification of products_new.php should work:

 

// the numbers of days that new products will be shown on this page is selected by
// the number subtracted from date("d"):
$time_lag = mktime(date("H"), date("i"), date("s"), date("m"), date("d")-90, date("Y"));
// creates the MySQL date time stamp from the UNIX date , example: 2004-12-06 10:02:44
$date_time_lag = date("Y-m-d H:i:s", $time_lag);
 $products_new_array = array();

 $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' AND p.products_date_added > '".$date_time_lag."' order by p.products_date_added DESC, pd.products_name";
 $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

Link to comment
Share on other sites

Brilliant. Works wonderfully for me.

 

I added a variable to more obviously and unobtrusively change the length of time that a product is "new".

 

I'd be much obliged if you'd release it as a contribution. I know at least a few other folks that will be pleased at this fix.

 

To summarize (for those following along at home), the code went from this:

 <?php
 $products_new_array = array();

 $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";
 $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

 if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>

 

to this:

<?php

//begin fixed code to only actually show "new" products as new products

$days_of_new_products = 180;

// the numbers of days that new products will be shown on this page is selected by $days_of_new_products
 $time_lag = mktime(date("H"), date("i"), date("s"), date("m"), date("d")-$days_of_new_products, date("Y"));

// creates the MySQL date time stamp from the UNIX date , example: 2004-12-06 10:02:44
 $date_time_lag = date("Y-m-d H:i:s", $time_lag);

 $products_new_array = array();

 $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' AND p.products_date_added > '".$date_time_lag."' order by p.products_date_added DESC, pd.products_name";

// end fix for new products 

 $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

 if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>

 

Can you then subtract the 30 day unix timestamp (2592000) from the $today_time variable, and then turn that into datetime format, to get the date that was 30 days previous?

iwik: I was trying to do that the other day, but couldn't easily find a function that turned unix time back into regular time. JanZ has done that nicely. :)

 

Thanks, all!

 

-jared

Link to comment
Share on other sites

Jane - - thanks for the link to that other thread. I like Jan's solution here better because it's the last x number of days, not just in the current calendar month. It's more flexible.

 

In fact, I think I'll post a link to this thread in that thread. :)

 

Thanks again!

 

-jared

Link to comment
Share on other sites

Interesting that suddenly three separate threads are started on the same subject whereas a contribution with a fix already was released.

 

In the thread: "New Product Time Limit, How long is a product "new"? ": ( http://www.oscommerce.com/forums/index.php?showtopic=124765 ) Emmet Brosnan (yesudo) refers to thread "Limit new products or bestsellers by date" ( http://www.oscommerce.com/forums/index.php?showtopic=85375 ) which in turn refers to his contribution "Limit new products or bestsellers by date" : http://www.oscommerce.com/community/contributions,1981

 

In Emmet's contribution the code is even shorter:

 

<?php

//begin fixed code to only actually show "new" products as new products

$days_of_new_products = 180;

?$products_new_array = array();

?$products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' AND TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) < ".$days_of_new_products." order by p.products_date_added DESC, pd.products_name";

// end fix for new products

Link to comment
Share on other sites

I like it! I *really* want to know more of this stuff. I'm getting sick of my 10 year old college memories being the only thing complimenting what I can figure out from the osC code. I need to buy a PHP/MySQL programming book and start to have a bit more structured learning.

 

-jared

Link to comment
Share on other sites

Brilliant.  Works wonderfully for me. 

 

I added a variable to more obviously and unobtrusively change the length of time that a product is "new".

 

I'd be much obliged if you'd release it as a contribution.  I know at least a few other folks that will be pleased at this fix.

 

To summarize (for those following along at home), the code went from this:

 <?php
 $products_new_array = array();

 $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";
 $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

 if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>

 

to this:

<?php

//begin fixed code to only actually show "new" products as new products

$days_of_new_products = 180;

// the numbers of days that new products will be shown on this page is selected by $days_of_new_products
 $time_lag = mktime(date("H"), date("i"), date("s"), date("m"), date("d")-$days_of_new_products, date("Y"));

// creates the MySQL date time stamp from the UNIX date , example: 2004-12-06 10:02:44
 $date_time_lag = date("Y-m-d H:i:s", $time_lag);

 $products_new_array = array();

 $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' AND p.products_date_added > '".$date_time_lag."' order by p.products_date_added DESC, pd.products_name";

// end fix for new products 

 $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

 if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>

iwik:  I was trying to do that the other day, but couldn't easily find a function that turned unix time back into regular time.  JanZ has done that nicely.  :)

 

Thanks, all!

 

-jared

 

Thank you all for this information ! I already had the What's New box disabled as it was showing everything which I didn't want and with my very littel to no PHP knowledge up to now I didn't know of any solution until I found this thread.

 

I implented the above code within product_new.php and changed the $days_of_new_products to several values to see if it worked and so it did :thumbsup:

 

Next thing I noticed however was that the new products within the What's New box weren't affected by this contribution and still showed everything randomly.

With the knowledge of the above at hand I changed /includes/boxes/whats_new.php

to the following:

 

//begin fixed code to only actually show "new" products as new products

$days_of_new_products = 180;

// the numbers of days that new products will be shown on this page is selected by $days_of_new_products
$time_lag = mktime(date("H"), date("i"), date("s"), date("m"), date("d")-$days_of_new_products, date("Y"));

// creates the MySQL date time stamp from the UNIX date , example: 2004-12-06 10:02:44
$date_time_lag = date("Y-m-d H:i:s", $time_lag);

$products_new_array = array();

 if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1'  AND products_date_added > '".$date_time_lag."' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {

 

and, a little bit to my surprise, it worked :D

Maybe this was already done somewhere within the mentioned contributions but after downloading and reading them all and not seeing the trees in the woods anymore I think the above and this should be clear to anyone wanting to have this done.

 

Greetings and thanks again for showing 'The Path' :D

 

Howard

Link to comment
Share on other sites

  • 3 weeks later...

hmm .. two things

 

why is my code like this

<?php
 $products_new_array = array();

 $products_new_query_raw = "select p.products_quantity, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";
 $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

 if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>

 

and why is this changing of codes not working for me ;) :rolleyes:

 

thanx

Link to comment
Share on other sites

hmm .. two things

 

why is my code like this

<?php
?$products_new_array = array();

?$products_new_query_raw = "select p.products_quantity, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";
?$products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

?if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>

 

and why is this changing of codes not working for me  ;)  :rolleyes:

 

thanx

 

I don't see any changes in your code :rolleyes:

Link to comment
Share on other sites

there is "p.products_quantity" inserted .. this is original file .. why is this not in yours versions?

 

I don't know why the orignal quantity has been left out of the changed query. You would have to ask the original writer for this but my guess is it wasn't neccessary for this query so why would you retrieve something you don't use ?!

 

Anyhow, besides that if you changed the code as shown it should work without problem. Of course you have to change the 180 days to something more close like 1 day or 5 days depending on your last product update. If you leave it at 180 days there is a big chance all your products will fall in this time period and nothing seems to be changed...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...