Book Image

Deep Inside osCommerce: The Cookbook

By : Monika Mathe
Book Image

Deep Inside osCommerce: The Cookbook

By: Monika Mathe

Overview of this book

osCommerce has been around since March 2000. At present there are over 10,000 live, registered osCommerce sites, and about 100,000 registered community members. Apart from providing ready-made solutions to problems, as well as a huge repository of information, the osCommerce community is a living entity with which we can all interact. With the rising success and popularity of this remarkable piece of software, things can only get better.
Table of Contents (17 chapters)
Deep Inside osCommerce: The Cookbook
Credits
Foreword
About the Author
About the Reviewers
Introduction

21. Sort Product Listing by Date Added


This recipe shows you how to sort your product listing by date. If you often add products and have long lists, this will be useful to focus on new items.

Presentation

Your product listing will change from the default sorting done alphabetically by product name to sorting by the date on which each product was added:

Ready for some date pudding? Enjoy!

Ingredients

Note

Modified:

catalog/index.php

Cooking

  1. 1. Open catalog/index.php and find the following code in line 191 where sorting is defined:

if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]',
$HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) >
sizeof($column_list)) ) {
for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
$HTTP_GET_VARS['sort'] = $i+1 . 'a';
$listing_sql .= " order by pd.products_name";
break;
}
}
} else {
  • Replace with the following code, modifying the sort order so that the date a product was added on is the...