[ic] Next Product, Previous Product.

Davor Ocelic docelic at spinlocksolutions.com
Thu Oct 2 22:51:39 UTC 2008

On Thu, 2 Oct 2008 15:20:03 -0700
"John Hoy" <johndhoy at gmail.com> wrote:

> Hi All,
> On my Flypage I want to be able to add <next product>, <previous
> product>.
> I have a small catalog and I just want to loop through it based on the
> SKU.  I cannot seem to find how to create this search.


This isn't implemented in Standard demo, as there is no notion 
of "previous" and "next" product.

It's simple to do it, though. If your SKUs are consecutive numbers
(or obtainable by formula given current SKU) you don't even need a search,
just provide a link to a flypage with SKU -1, +1 or similar.

If not, then a simple SQL query (or two actually) that return the
previous and next SKU will do.

That implies your SQL column is of proper type so that you can 
use < and > operators.

Something like this would work (untested):

 sql="(select sku from products where id < $THIS order by id desc limit 1)
       union all (select sku from products where id > $THIS order by id limit 1)"

  [sql-alternate 2]
    Previous product, [sql-code]
    Next product, [sql-code]



More information about the interchange-users mailing list