Mashup “New Products for month”

By | September 9, 2008

The standard “new products for month” box on the front page of most osCommerce sites is a complete waste of time. It just shows the last “x” (usually 9) products that were added/amended. Useless!

Here’s a few ideas – open up /includes/modules/new_products.php

1. How about getting 9 RANDOM items to show? Easy.

Find this code;

[php]$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);[/php]

Change it to this;

[php]$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 RAND() limit ” . MAX_DISPLAY_NEW_PRODUCTS);[/php]

No good? Ok, revert back to the original file…

2. How about only showing Special Offers, randomly?

Find this:

[php]$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);[/php]

Change it to this:

[php]$new_products_query = tep_db_query(“select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_prix 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 . “‘ and s.status = ‘1’ order by RAND() limit ” . MAX_DISPLAY_NEW_PRODUCTS);[/php]

Find this:

[php]’text’ => ‘‘ . tep_image(DIR_WS_IMAGES . $new_products[‘products_image’], $new_products[‘products_name’], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . ‘
‘ . $new_products[‘products_name’] . ‘
‘ . $currencies->display_price($new_products[‘products_price’], tep_get_tax_rate($new_products[‘products_tax_class_id’])));[/php]

Change it to this:

[php]’text’ => ‘‘ . tep_image(DIR_WS_IMAGES . $new_products[‘products_image’], $new_products[‘products_name’], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . ‘
‘ . $new_products[‘products_name’] . ‘
‘ . $currencies->display_price($new_products[‘products_price’], tep_get_tax_rate($new_products[‘products_tax_class_id’])) . ‘ ‘ . $currencies->display_price($new_products[‘products_prix’], tep_get_tax_rate($new_products[‘products_tax_class_id’])) . ‘‘);[/php]

No good? OK, let’s revert back to the original file.

3. How about having the product name and price alongside the image?

Find this:

[php]’align’ => ‘center’,[/php]

Change it to this:

[php]’align’ => ‘left’,[/php]

Find this:

[php]’text’ => ‘‘ . tep_image(DIR_WS_IMAGES . $new_products[‘products_image’], $new_products[‘products_name’], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . ‘
‘ . $new_products[‘products_name’] . ‘
‘ . $currencies->display_price($new_products[‘products_price’], tep_get_tax_rate($new_products[‘products_tax_class_id’])));[/php]

Change it to this:

[php]’text’ => ‘‘ . tep_image(DIR_WS_IMAGES . $new_products[‘products_image’], $new_products[‘products_name’], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, ‘align=”left”‘) . ‘‘ . $new_products[‘products_name’] . ‘
‘ . $currencies->display_price($new_products[‘products_price’], tep_get_tax_rate($new_products[‘products_tax_class_id’])));[/php]

Still Not Happy? OK, let’s mash the whole lot…

4. Make it Specials only, random order, with the price and name at the side of each

Find this:

[php]$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);[/php]

Change it to this:

[php]$new_products_query = tep_db_query(“select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, if(s.status, s.specials_new_products_price, p.products_price) as products_prix from ” . TABLE_PRODUCTS . ” p left join ” . TABLE_SPECIALS . ” s on p.products_id = s.products_id where products_status = ‘1’ and s.status = ‘1’ order by RAND() desc limit ” . MAX_DISPLAY_NEW_PRODUCTS);[/php]

Find this:

[php]’align’ => ‘center’,[/php]

Change it to this:

[php]’align’ => ‘left’,[/php]

Find this:

[php]’text’ => ‘‘ . tep_image(DIR_WS_IMAGES . $new_products[‘products_image’], $new_products[‘products_name’], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . ‘
‘ . $new_products[‘products_name’] . ‘
‘ . $currencies->display_price($new_products[‘products_price’], tep_get_tax_rate($new_products[‘products_tax_class_id’])));[/php]

Change it to this:

[php]’text’ => ‘‘ . tep_image(DIR_WS_IMAGES . $new_products[‘products_image’], $new_products[‘products_name’], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, ‘align=”left”‘) . ‘‘ . $new_products[‘products_name’] . ‘
‘ . $currencies->display_price($new_products[‘products_price’], tep_get_tax_rate($new_products[‘products_tax_class_id’])) . ‘ ‘ . $currencies->display_price($new_products[‘products_prix’], tep_get_tax_rate($new_products[‘products_tax_class_id’])) . ‘‘);[/php]

As you can see, it’s easily possible to amend the SQL to get what you need from the database and it is easy to amend the HTML to layout the info you got from the database.

osCommerce is easy as 123, eh?

One thought on “Mashup “New Products for month”

Leave a Reply

Your email address will not be published.