Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

2.3.4.1 CE - What's New displaying all 6,000 items in website


Guest

Recommended Posts

The What's New box - when clicked takes me to catalog/products_new.php - is displaying results for every single item in the website.

Is there something in Admin that controls how many should be displayed?  All of my numbers in Maximum values are set to ten or less.

???

- Andrea

Link to comment
Share on other sites

@puggybelle

In /includes/modules/boxes/bm_whats_new.php, there is this code snippet:

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

The number of items displayed is limited by MAX_RANDOM_SELECT_NEW

This is created and defined as part of the installation process. I do not see where it is configurable in Admin. If you have access to a program such as phpMyAdmin, look at your configuration table. In my installation, it is around line 42, and the number entered is 10.

HTH

M

Link to comment
Share on other sites

5 hours ago, ArtcoInc said:

1) Ensure that your copy of /includes/modules/boxes/bm_whats_new.php is correct

It is correct.  It's the same file that came with the install.  No changes.

5 hours ago, ArtcoInc said:

Try echoing out what osC thinks is MAX_RANDOM_SELECT_NEW

I don't know what you mean or how to do that.  How is echoing something out going to achieve a box count of ten items?  All I'm thinking is...yes...that setting really is in Admin and the database is saying show only ten yet it shows ALL.

It did this with the stock install of dummy items, too.  I noticed this before I imported my own 2.2 database.  All 'fake' items showing onscreen in catalog/products_new.php  Twenty-eight or so, despite the fact the database says MAX_RANDOM_SELECT_NEW is 10.

The code is not respecting the value assigned in the database.  Still stuck.

But Thank You for talking to me!

- Andrea

 

Link to comment
Share on other sites

You say you imported your database from 2.2? The whole database structure or only certain tables?

Could it be that you have the MAX_RANDOM_SELECT_NEW definition twice in there?

Link to comment
Share on other sites

@puggybelle  echo out variables...

echo MAX_RANDOM_SELECT_NEW;
// or
printf("%s<br>",MAX_RANDOM_SELECT_NEW);
// or
var_dump(MAX_RANDOM_SELECT_NEW);

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

//here you can't echo out an array...
var_dump($random_product);
// or
print_r($random_product);
// none of this print you have other issues. $random_product == false.

 

Link to comment
Share on other sites

I'm afraid you guys are chasing a red herring here. The variable

MAX_RANDOM_SELECT_NEW

governs the number of most recent new things from which one is chosen for the box. If it's 10, you get one of the 10 newest things.

The page products_new does show all the site's products in reverse order of products_id ie. newest first, a page at a time. You can choose how many you see in a page, but you get all of them.

This is true of both classic 2.3.4.1 and 2.3.4.1CE and I think it's always been the core design.

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

Ah! 
Yes that is true it does show all products but splits them up in pages. I thought she meant 6000 on one page which would mean endless long scrolling. lol
The MAX_ whatever limits only the products per page result and not the total amount of products.

Wasn't that like that since... always. Even the old 2.2 days?

Link to comment
Share on other sites

you can control the max products in this line in includes/modules/product_listing.php:

  $num_list = (isset($_GET['view']) && ($_GET['view'] == 'all') ) ? 999999 : MAX_DISPLAY_SEARCH_RESULTS; 

 

Link to comment
Share on other sites

5 minutes ago, raiwa said:

you can control the max products in this line in includes/modules/product_listing.php:


  $num_list = (isset($_GET['view']) && ($_GET['view'] == 'all') ) ? 999999 : MAX_DISPLAY_SEARCH_RESULTS; 

 

Yes, but not if it's paged which is the default view. If you set view=all as the canonical url it will limit how many are shown to a search engine, but that won't help Andrea...

and it will affect all product listings, not just the new products page.

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

I added some code in my old 2.2 site that controls how many items are returned.

The products_new page (What's New Infobox) is not set to return a specific number of items, only items created in the last 30 calendar days.  When clicked, it could show results for ten items.  It might be 35.  Depends on how much work I've done (or not!).  It only returns items introduced in the last thirty days.

But, like everything else in my old site, I fear I won't be able to replicate it in the new one.  The folder/file structure in the new release is...at the moment...too complicated for me to work with.  Code that used to be in one file is now scattered across many files and I have no idea where to find anything anymore.

Thusly, I've been posting a lot lately with questions that are easily answered for 2.2, but this one?  Not so much.  I find 2.3.4.1 CE very difficult to work with.  I'm hopeful that it will get easier over time, the more I familiarize myself with it.  Not having fun yet, though.

Link to comment
Share on other sites

And it's Tsimi to the rescue, once again!

I changed the listing sql code in catalog/products_new.php (using the info supplied by Germ in Tsimi's link above) and now I only have new items introduced in the last 30 days.  Find this chunk of code in the middle of the file:

$listing_sql = "select " . $select_column_list . " p.products_id, SUBSTRING_INDEX(pd.products_description, ' ', 20) as products_description, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price, p.products_quantity as in_stock, if(s.status, 1, 0) as is_special from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'";

  if ( (!isset($_GET['sort'])) || (!preg_match('/^[1-8][ad]$/', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) ) {
    for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
      if ($column_list[$i] == 'PRODUCT_LIST_ID') {
        $_GET['sort'] = $i+1 . 'd';
        $listing_sql .= " order by p.products_id DESC";
        break;

And replace it with this:

$mdy = strftime(DATE_FORMAT_SHORT, time() - (30 * 24 * 60 * 60) );
  $listing_sql = "select " . $select_column_list . " p.products_id, SUBSTRING_INDEX(pd.products_description, ' ', 20) as products_description, p.products_date_added, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price, p.products_quantity as in_stock, if(s.status, 1, 0) as is_special from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_date_added >= '" . tep_date_raw($mdy) . "'";

  if ( (!isset($_GET['sort'])) || (!preg_match('/^[1-8][ad]$/', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) ) {
    for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
      if ($column_list[$i] == 'PRODUCT_LIST_ID') {
        $_GET['sort'] = $i+1 . 'd';
        $listing_sql .= " order by p.products_date_added DESC";
        break;

Anyone see issues with it?  I'm not a programmer.  Works for me!  12 products listed which means...I really need to do some work.  I normally have around 30!

- Andrea

Link to comment
Share on other sites

What if the last time they visited your site was 40 days ago or longer?  With the core design they can just look at however many new products interest them, one page at a time.

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

@puggybelle

Which do you want ....

* To display all of the new products added within the last X days (ex: the last 30 days), even if nothing has been added during this period (and hence, nothing will show), or there may be a LOT of new products? Or,

* To display the last Y added products (ex: the last 10 added products, sorted by add date), even if some of those 'new' products may have been added over a year ago?

M

Link to comment
Share on other sites

8 hours ago, BrockleyJohn said:

What if the last time they visited your site was 40 days ago or longer?

Why would I continue to browse an online store whose inventory never changes?

5 hours ago, ArtcoInc said:

Which do you want ....

* To display all of the new products added within the last X days (ex: the last 30 days), even if nothing has been added during this period (and hence, nothing will show), or there may be a LOT of new products? Or,

* To display the last Y added products (ex: the last 10 added products, sorted by add date), even if some of those 'new' products may have been added over a year ago?

I'm perfectly happy with my 30 day solution as I've always had it that way in my old site.  When the number of items in that page starts to drop, it really does serve as a motivator for me to do some work and add new things. 

I expect different sellers need different solutions for this one.  I'm most fond of the second one you mentioned.  No pressure to add new things at all.  Not the way to go for me, but perhaps someone else prefers that.

Maybe some sellers shouldn't even use the What's New box at all.  I think it depends on what you're doing or what you're selling.

My buyers expect to see new things.  The What's New box is a high priority click for my repeat customers.  Your situation may be totally different.

- Andrea

Link to comment
Share on other sites

I have updated this addon to work with Frozen https://apps.oscommerce.com/iCbgv

but I have not published it as it changes core code instead of being a module and I fear being shot down.

However it works perfectly.

It provides the ability to change the number of days for Best Seller days and New Product days under Maximum Values in admin

image.thumb.png.9dccfdac75b1b972fbfcd3b993e03713.png

4 files to amend and 2 SQL routines and it's done 

If them that knows think it is suitable as an addon then I will publish it

Here are the instructions Best Sellers for Frozen.zip

 

Live shop Phoenix 1.0.8.4 on PHP 7.4 Working my way up the versions.

Link to comment
Share on other sites

@mhsuffolk some things are impossible without core changes (like changing the queries) but if different behaviour is required in a module you can offer an alternative module to be installed instead of the core one, then that at least won't get overwritten by other changes.

Core changes best avoided when possible but not anathema. If people recognise that they make future upgrades harder by changing their core code, that's their decision.

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...