Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Setting the number of products, or new products displayed & limiting age of new products shown


spooks

Recommended Posts

Setting the number of products, or new products displayed & limiting the age of new products shown.

 

These are often asked & I don't think there is a tip covering all the above, so here's my solutions.

 

Backup your site files before making any of the changes given.

 

How to set number of products displayed within categories:

 

Admin -> Maximum Values -> Search Results

 

That setting is used for both your normal product display & search results, annoyingly it also sets the display limit in admin!!

 

How to set number of new products shown on the home page

 

The products shown on the home page are displayed with the new_products.php module (found in includes/modules) to limit the number shown:

 

Admin -> Maximum Values -> New Products Module

 

How to set the maximum age for new products shown on the home page

By default there is no age limit!! The module will simply display products of any age, only limiting the number by the setting above, to set a date limit (or age) you must add some code:

 

in includes/modules/new_products.php

 

after:

 

$info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

 

add:

 

$ndate = strtotime("-60 days"); // set max age of displayed product
$ndate = strftime("%Y-%m-%d",$ndate); 

 

find:

 

 

$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

} else {

$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

 

Replace with:

 

$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' and p.products_date_added > '".$ndate."' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

} else {

$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p.products_date_added > '".$ndate."' and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

 

 

How to set maximum number of new products shown in the new products page

 

The products shown in the new products page are displayed with the products_new.php (found in your catalog folder) to limit the number shown:

 

Admin -> Maximum Values -> New Products Listing

 

How to set the maximum age for new products displayed in the new products page

By default there is no age limit!! The page will simply display products of any age, only limiting the number by the setting above, to set a date limit (or age) you must add some code:

 

in products_new.php

 

find:

 

$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_PRODUCTS_NEW));

 

add after:

 

$ndate = strtotime("-60 days"); // set max age of displayed product
$ndate = strftime("%Y-%m-%d",$ndate); 

 

find:

 

$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";

 

replace with:

 

$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 p.products_date_added > '".$ndate."' and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";

 

How to set the maximum age for products displayed in the what's new info box

 

By default there is no age limit!! (Are you detecting a pattern here!) The box will simply display products of any age, randomly selecting a new product from the X number of the latest products. X having been set with:

 

Admin -> Maximum Values -> Random New Products

 

To set a age limit (or date limit since added) you must add some code:

 

in includes/boxes/whats_new.php

 

after:

 

Released under the GNU General Public License
*/

 

add:

 

$bdate = strtotime("-60 days"); // set max age of displayed product
$bdate = strftime("%Y-%m-%d",$bdate);

 

Find:

 

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)) {

 

Replace with:

 

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 > '".$bdate."' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {

 

Note: with this modification, if there are no products within the date range the what's new box will simply not appear.

 

 

I hope that covers its all. smile.gif

 

If you prefer, I have uploaded the same info plus modified files as a contribution here

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

AND p.products_date_added > date_sub(NOW( ), INTERVAL 1 MONTH)

 

http://dev.mysql.com...nction_date-add

 

 

That's another way, the only trouble with using NOW() though is it is always the server time, whereas, with everything set correct, php date functions will return local time.

 

I also felt it was easier for others to alter the way I have put it, thanks anyway.smile.gif

 

 

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

If now() doesn't float your boat, then date_default_timezone_set and work from that.

 

I really hate seeing solutions that are well thought, then poorly executed sad.gif

 

 

I don't see what your issue is, setting the correct timezopne is clearly outside the scope of this contrib. There are already post/contribs that deal with that anyway.

 

Your solution means the installer is modifying the SQL, many have enough trouble with addons & getting errors, encoraging them to do risky stuff with the SQL they could easily mess up I feel is a bad way.

 

If you have a better solution than mine in php, please provide it, (is 2 lines too much!!) wink.gif

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

I already provided a better solution, however my code is part of the native SQL and if the person wants to change the INTERVAL at which products stop being shown they can do so easily enough.

 

All in all, the concept is great - don't get me wrong. I am simply saying it can be done better, and I have supplied the tiny piece of code that in my opinion makes it better which you immediately rejected for no apparent reason except a general dumbing down of the average oscommerce user. Let's start empowering people rather than sheepifying them.

 

Remember, opinions are like arseholes - everyone has one, and some are bigger than others ;)

Link to comment
Share on other sites

 

 

Perhaps I am pandering to the lowest common denominator, but I have a lot of contribs & many manage to get the simplest stuff wrong, so now I try to do stuff that all will find easy & none challenging, is that so bad!! It also lessons the same answers I keep having to repeat, over & over!!

 

Those wanting a challenge can easily find it here after all. smile.gif

 

PS Denegration, by any means, is a reflection.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

That's another way, the only trouble with using NOW() though is it is always the server time, whereas, with everything set correct, php date functions will return local time.
Since the products_date_added would be in MYSQL time and the $ndate would be in PHP time, you can end up with -60 days turning into anything from -59 days 1 hour to -60 days 23 hours. If you used Gary's code, it would *always* be -60 days, regardless of server time or local time differences, as it would always be using the same reference time for both. In fact, it even works if the time zone is wrong.

 

You in fact introduced the bug that you were trying to avoid.

 

Another bug that arises is when you change time zones per language. E.g. someone who does business with both the US and Japan, so english.php has a US time zone and nipponese.php has a Japanese time zone. With your code, it can show different products when you change languages. With Gary's code, it will always show the same products.

 

The only time that you would want to do something like your $ndate code would be if you wanted to show all products added in the current month. That should give different products for different time zones, so it would make sense to do things with local time. You would still want to do a time zone adjustment, as products_date_added would still be in MySQL time. E.g.

  $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' and month(convert_tz(p.products_date_added, 'SYSTEM', '" . tep_db_input(date('P')) . "')) = '" . (int)date('n') . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
} else {
 $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and month(convert_tz(p.products_date_added, 'SYSTEM', '" . tep_db_input(date('P')) . "')) = '" . (int)date(n) . "' and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

Warning: the date('P') syntax will only work in PHP 5.1.3 or greater. Prior to that, you'd have to do something else to get that information. E.g. hard code the time zone or if your MySQL supports it, use date('T').

 

You shouldn't fear making changes in MySQL. Sometimes, like here, it is the right place to make them. Particularly since you were actually comparing with a value in a MySQL change that you were adding. By using PHP in this context, you actually made the problem more complex (mixing PHP and MySQL date handling) and introduced the bug.

Always back up before making changes.

Link to comment
Share on other sites

 

Thanks for that, my only issue would be the assumption that products_date_added would be in MYSQL time, when I set up a UK store I ensure all dates used are local (ie now() is replaced) I feel its best that everything is consistant.

 

Anyway, is the tiny snippit of code really worth the discussion? Poeple can use whichever method they're happiest with now smile.gif .

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Thanks for that, my only issue would be the assumption that products_date_added would be in MYSQL time, when I set up a UK store I ensure all dates used are local (ie now() is replaced) I feel its best that everything is consistant.
So in other words, your tip is only appropriate for a store that you set up. It's not valid for a store with the default setup.

 

In general, the best practice when dealing with dates is to store them in the database as UTC and then modify them for display. That works both for UK only stores and for stores that do transactions in multiple time zones. It's impossible for everything to be consistent for all stores, as multiple time zones exist.

 

The main thing that made the discussion worth having was that prior to it, people might have thought that they could add your code to a store with the default setup and have it work. Now they know that if they have the default setup, they should use Gary's code. Or they should go through the entire osCommerce code base and change NOW() to PHP time wherever it appears. They should of course do this *before* adding any products.

 

They can also use this to find out that the contribution that you uploaded is incomplete, since it requires a modified RC2A to function but you did not include any of the other files that would make everything consistent.

Always back up before making changes.

Link to comment
Share on other sites

First of all, thank you so much for this detailed list - it is awesome! I am having one issue though - while trying to perform the following portion, I run into a problem because my .php file does not have the $products_new_query_raw code anywhere.

 

 

How to set the maximum age for new products displayed in the new products page

By default there is no age limit!! The page will simply display products of any age, only limiting the number by the setting above, to set a date limit (or age) you must add some code:

 

in products_new.php

 

find:

 

$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_PRODUCTS_NEW));

 

add after:

 

$ndate = strtotime("-60 days"); // set max age of displayed product
$ndate = strftime("%Y-%m-%d",$ndate); 

 

find:

 

$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";

 

replace with:

 

$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 p.products_date_added > '".$ndate."' and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";

 

this is what mine looks like:

 

<?php
/*
 $Id: products_new.php,v 1.1.1.1 2004/03/04 23:38:02 ccwjr Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License

this file gets all the reaw data needed by product_listing and product_listing_column to build
the display

*/

 require('includes/application_top.php');

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCTS_NEW);

 $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
                      'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
                      'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
                      'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
                      'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
                      'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
                      'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
                      'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

 asort($define_list);

 $column_list = array();
 reset($define_list);
 while (list($key, $value) = each($define_list)) {
   if ($value > 0) $column_list[] = $key;
 }

 $select_column_list = '';
 $need_manufacturer = false;
 $need_price = false;
 for ($i = 0, $n = sizeof($column_list); $i < $n; ++$i) {
   switch ($column_list[$i]) {
     case 'PRODUCT_LIST_MODEL':
       $select_column_list .= 'p.products_model, ';
       break;
     case 'PRODUCT_LIST_NAME':
       $select_column_list .= 'pd.products_name, ';
       break;
     case 'PRODUCT_LIST_MANUFACTURER':
       $select_column_list .= 'm.manufacturers_name, ';
       $need_manufacturer = true;
       break;
     case 'PRODUCT_LIST_QUANTITY':
       $select_column_list .= 'p.products_quantity, ';
       break;
     case 'PRODUCT_LIST_IMAGE':
       $select_column_list .= 'p.products_image, ';
       break;
     case 'PRODUCT_LIST_WEIGHT':
       $select_column_list .= 'p.products_weight, ';
       break;
     case 'PRODUCT_LIST_PRICE':
       $need_price = true;
       break;
   }
 }

 // start building the sql
 $listing_sql = "SELECT DISTINCT " . $select_column_list . "  
                         p.products_id,
                         p.products_image ";
 if ($need_price === true) {
   $listing_sql .= "    , p.products_price,
                         p.products_tax_class_id,
                         IF(s.status, LEAST(s.specials_new_products_price, p.products_price), p.products_price) as final_price ";
 }
 // add the tables to be selected from
 if ($need_price === true && $need_manufacturer === true) {
   $listing_sql .= "  FROM (" . TABLE_PRODUCTS . " p 
                      LEFT JOIN " . TABLE_SPECIALS . " s using(products_id) )
                      LEFT JOIN " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id,
                        " . TABLE_PRODUCTS_DESCRIPTION . " pd ";
 } elseif ($need_price === true) {
   $listing_sql .= "  FROM (" . TABLE_PRODUCTS . " p 
                      LEFT JOIN " . TABLE_SPECIALS . " s using(products_id) ),
                       " . TABLE_PRODUCTS_DESCRIPTION . " pd ";
 } elseif ($need_manufacturer === true) {
   $listing_sql .= "  FROM (" . TABLE_PRODUCTS . " p 
                      LEFT JOIN " . TABLE_MANUFACTURERS . " m using(manufacturers_id) ),
                        " . TABLE_PRODUCTS_DESCRIPTION . " pd ";
 } else {
   $listing_sql .= "  FROM " . TABLE_PRODUCTS . " p,
                        " . TABLE_PRODUCTS_DESCRIPTION . " pd ";
 }
 // now add the where conditions
 $listing_sql .= "  WHERE p.products_status = '1'
                      AND pd.products_id = p.products_id
                      AND pd.language_id = '" . (int)$languages_id . "'
                      AND DATE_SUB(CURDATE(),INTERVAL " . NEW_PRODUCT_INTERVAL . " DAY) <= p.products_date_added "; 
 // and finially add the order by as needed
 if ( (!isset($_GET['sort'])) || (!ereg('[1-8][ad]', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) ) {
   $sort_column = CATEGORIES_SORT_ORDER;
   $sort_order = 'a';
 } else {
   $sort_col = substr($_GET['sort'], 0 , 1);
   $sort_column = $column_list[$sort_col-1];
   $sort_order = substr($_GET['sort'], 1);
 }
 // check to see if it is one of the columns being allowed for
 switch ($sort_column) {
   case 'PRODUCT_LIST_MODEL':
     $listing_sql .= " order by p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
      break;
   case 'PRODUCT_LIST_NAME':
     $listing_sql .= " order by pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
     break;
   case 'PRODUCT_LIST_MANUFACTURER':
     $listing_sql .= " order by m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
     break;
   case 'PRODUCT_LIST_QUANTITY':
     $listing_sql .= " order by p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
     break;
   case 'PRODUCT_LIST_IMAGE':
     // sorting by image name makes no sense, so just ignore it
     break;
   case 'PRODUCT_LIST_WEIGHT':
     $listing_sql .= " order by p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
     break;
   case 'PRODUCT_LIST_PRICE':
     $listing_sql .= " order by final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
     break;
 }

 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_PRODUCTS_NEW));
$ndate = strtotime("-2 days"); // set max age of displayed product
$ndate = strftime("%Y-%m-%d",$ndate); 
 $content = CONTENT_PRODUCTS_NEW;

 require(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/' . TEMPLATENAME_MAIN_PAGE);

 require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

 

Am I just missing it?

 

Also, what do I need to do to remove the randomization? I wangt th eproducts to show up in the order last uploaded.

 

Thanks in advance for any help you can provide!

 

Jeana

Link to comment
Share on other sites

 

 

It seems u have a template with stuff moded for it, there is already a date limiting option there, but perhaps there's an issue elsewhere with that?

 

after:

require('includes/application_top.php');

add:

 

$ndate = strtotime("-60 days"); // set max age of displayed product
$ndate = strftime("%Y-%m-%d",$ndate);

 

change:

 

AND pd.products_id = p.products_id

to

 

AND pd.products_id = p.products_id AND p.products_date_added > '".$ndate."' 

 

your sorting also has some code changes from the default, but try this:

 

change:

 

	$sort_column = CATEGORIES_SORT_ORDER;  
$sort_order = 'a';

 

to

 

$listing_sql .=  " order by p.products_date_added DESC, pd.products_name";	
$sort_column = '';
$sort_order = 'd';

 

Hope that sorts it for you. smile.gif

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Thank you sooooo much!

 

It seems u have a template with stuff moded for it, there is already a date limiting option there, but perhaps there's an issue elsewhere with that?

 

after:

require('includes/application_top.php');

add:

 

$ndate = strtotime("-60 days"); // set max age of displayed product
$ndate = strftime("%Y-%m-%d",$ndate);

 

change:

 

AND pd.products_id = p.products_id

to

 

AND pd.products_id = p.products_id AND p.products_date_added > '".$ndate."' 

 

your sorting also has some code changes from the default, but try this:

 

change:

 

	$sort_column = CATEGORIES_SORT_ORDER;  
$sort_order = 'a';

 

to

 

$listing_sql .=  " order by p.products_date_added DESC, pd.products_name";	
$sort_column = '';
$sort_order = 'd';

 

Hope that sorts it for you. smile.gif

Link to comment
Share on other sites

  • 2 months later...

Sorry to bump up this thread but i had a question about 'How to set the maximum age for new products shown on the home page'. Will that set it to the complete maximum age or just 60 days if i copied that code? If it doesn't set the complete maximum age then is it possible to do so?

Link to comment
Share on other sites

Sorry to bump up this thread but i had a question about 'How to set the maximum age for new products shown on the home page'. Will that set it to the complete maximum age or just 60 days if i copied that code? If it doesn't set the complete maximum age then is it possible to do so?

 

 

I don't know what you mean by complete maximum age, there is only one product age, the limit says any products older than 60 days (or whatever you set) are not considered 'new' so wont be displayed.

 

A products age is the days since it was added.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

I don't know what you mean by complete maximum age, there is only one product age, the limit says any products older than 60 days (or whatever you set) are not considered 'new' so wont be displayed.

 

A products age is the days since it was added.

 

Sorry i read that wrong and confused myself!

 

Is there anyway i can get the homepage to rotate all products? Is that a different module?

Link to comment
Share on other sites

 

Is there anyway i can get the homepage to rotate all products? Is that a different module?

 

Not with standard osc, look in the add-ons section for all products contribs.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

  • 1 month later...

Thanks for the great info! I'm trying to set my homepage to display all the products on my store, but I don't want it to just be a never-ending list. Can it be set to show only like 30 then go to the next page?

 

Thanks!

Link to comment
Share on other sites

Thanks for the great info! I'm trying to set my homepage to display all the products on my store, but I don't want it to just be a never-ending list. Can it be set to show only like 30 then go to the next page?

 

Thanks!

 

 

You would have to modify the code to achieve that, osC allows you to set a limit for the new_products module to display, but it does not allow for paging in that.

 

 

There is a contrib for displaying all products, I`m sure that has paging.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

  • 1 month later...

Just a post to say thank you for the code. I only used the products_new part but it does what I was looking for bringing the items listed to a managable number rather than dispalying my whole catalogue of page after page after page of "old" products.

 

Cheers

I'm feeling lucky today......maybe someone will answer my post!

I do try and answer a simple post when I can just to give something back.

------------------------------------------------

PM me? - I'm not for hire

Link to comment
Share on other sites

Hey Sam, I am working on this site www.backstageny.com/shop .... How would I make the homepage display 4 columns instead of 3 for the New Products? I included my new_products.php file. Let me know if you need anything else...

 

<?php

// $info_box_contents = array();

// $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

// new contentBoxHeading($info_box_contents);

if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {

$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_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 limit " . MAX_DISPLAY_NEW_PRODUCTS);

} else {

$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and 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 limit " . MAX_DISPLAY_NEW_PRODUCTS);

}

$row = 0;

$col = 0;

$info_box_contents = array();

while ($new_products = tep_db_fetch_array($new_products_query)) {

// ----------

$product_query = tep_db_query("select products_description, products_id from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$new_products['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

$product = tep_db_fetch_array($product_query);

$p_id = $product['products_id'];

 

$p_pic = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';

 

$p_name = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a>';

 

$p_desc = ''.substr(strip_tags($product['products_description']), 0, MAX_DESCR_1).' ...';

 

$p_price = '<span class="productSpecialPrice">'.$currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])).'</span>';

 

$p_details = '<a href="' . tep_href_link('product_info.php?products_id='.$p_id) . '">'.tep_image_button('button_details2.gif', '', ' class="btn1"').'</a>';

$p_buy_now = '<a href="'.tep_href_link("products_new.php","action=buy_now&products_id=".$p_id).'">'.tep_image_button('button_add_to_cart2.gif', '', ' class="btn2"').'</a>';

 

 

 

$info_box_contents[$row][$col] = array('align' => 'left',

'params' => ' style="width:33%;"',

'text' => ''.tep_draw_prod2_top().'

<table cellpadding="0" cellspacing="0" border="0">

<tr><td class="name name2_padd">'.$p_name.'</td></tr>

<tr><td class="pic2_padd">'.tep_draw_prod_pic_top().''.$p_pic.''.tep_draw_prod_pic_bottom().'</td></tr>

<tr><td>'.tep_draw_price_top().'

<table cellpadding="0" cellspacing="0" border="0">

<tr>

<td class="price2_padd">'.$p_price.'</td>

<td class="button2_padd" align="right">'.$p_details.'</td>

</tr>

</table>

<div class="button_marg" align="right">'.$p_buy_now .'</div>

'.tep_draw_price_bottom().'

</td></tr>

</table>

'.tep_draw_prod2_bottom().'');

 

$col ++;

if ($col > 2) {

$col = 0;

$row ++;

}

}

new contentBox($info_box_contents);

?>

Link to comment
Share on other sites

  • 1 year later...

i have questions is there an easier way of setting the number of products,limiting the age of new products?Are there any add ons that would help me to sell downloadable files?I am trying to create an online store that sell downloadable PDFs and MP3s.

Link to comment
Share on other sites

There are other methods, but they wont be any easier.

 

There are contributions for down-loadable media, I`ve not used any so can't be specific.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

@@mailey1974

 

osC is a steep learning curve at the start and you do need to do a fair bit of research & reading before it becomes clear, but I don't think there are any e-commerce apps that are easy.

 

This thread is a good start http://www.oscommerce.com/forums/topic/307356-oscommerce-road-map-for-the-newbies/

 

It details many of the basics, like where to find things.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...