Index: openacs-4/packages/ecommerce/www/index-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/index-oracle.xql,v
diff -u -r1.4.8.1 -r1.4.8.2
--- openacs-4/packages/ecommerce/www/index-oracle.xql 23 Dec 2004 06:39:05 -0000 1.4.8.1
+++ openacs-4/packages/ecommerce/www/index-oracle.xql 11 Jun 2005 05:39:51 -0000 1.4.8.2
@@ -23,15 +23,34 @@
+
+
+ select count(*) as product_count
+ from ec_products_searchable p, ec_user_session_offer_codes o
+ where (p.product_id(+)=o.product_id and user_session_id = :user_session_id)
+ and not exists (select 1
+ from ec_category_product_map m
+ where p.product_id = m.product_id)
+
+
+
+ select r.*
+ from (
+ select rownum as r_rownum, q.*
+ from (
select p.product_id, p.product_name, p.one_line_description, o.offer_code
from ec_products_searchable p, ec_user_session_offer_codes o
where (p.product_id(+)=o.product_id and user_session_id = :user_session_id)
and not exists (select 1
from ec_category_product_map m
where p.product_id = m.product_id)
order by p.product_name
+ ) q
+ ) r
+ where r_rownum > :start_row
+ and r_rownum <= :start_row + :how_many
Index: openacs-4/packages/ecommerce/www/index-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/index-postgresql.xql,v
diff -u -r1.4.8.1 -r1.4.8.2
--- openacs-4/packages/ecommerce/www/index-postgresql.xql 23 Dec 2004 06:39:05 -0000 1.4.8.1
+++ openacs-4/packages/ecommerce/www/index-postgresql.xql 11 Jun 2005 05:39:51 -0000 1.4.8.2
@@ -23,14 +23,24 @@
+
+
+ select count(*) as product_count
+ from ec_products_searchable p left outer join ec_user_session_offer_codes o on (p.product_id = o.product_id and user_session_id = :user_session_id)
+ where not exists (select 1
+ from ec_category_product_map m
+ where p.product_id = m.product_id)
+
+
+
select p.product_id, p.product_name, p.one_line_description, o.offer_code
from ec_products_searchable p left outer join ec_user_session_offer_codes o on (p.product_id = o.product_id and user_session_id = :user_session_id)
where not exists (select 1
from ec_category_product_map m
where p.product_id = m.product_id)
- order by p.product_name
+ order by p.product_name limit :how_many offset :start_row
Index: openacs-4/packages/ecommerce/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/index.tcl,v
diff -u -r1.6.2.2 -r1.6.2.3
--- openacs-4/packages/ecommerce/www/index.tcl 23 Dec 2004 13:18:23 -0000 1.6.2.2
+++ openacs-4/packages/ecommerce/www/index.tcl 11 Jun 2005 05:39:51 -0000 1.6.2.3
@@ -4,7 +4,7 @@
@param usca_p
@param how_many
- @param start
+ @param start_row
@author
@creation-date
@@ -15,7 +15,7 @@
} {
usca_p:optional
{how_many:naturalnum {[ad_parameter -package_id [ec_id] ProductsToDisplayPerPage ecommerce]}}
- {start "0"}
+ {start_row "0"}
}
# see if they're logged in
@@ -95,54 +95,58 @@
set count 0
# find all top-level products (those that are uncategorized)
+db_1row get_tl_product_count "
+ select count(*) as product_count
+ from ec_products_searchable p left outer join ec_user_session_offer_codes o on (p.product_id = o.product_id and user_session_id = :user_session_id)
+ where not exists (select 1
+ from ec_category_product_map m
+ where p.product_id = m.product_id)"
db_foreach get_tl_products "
select p.product_id, p.product_name, p.one_line_description, o.offer_code
from ec_products_searchable p left outer join ec_user_session_offer_codes o on (p.product_id = o.product_id and user_session_id = :user_session_id)
where not exists (select 1 from ec_category_product_map m where p.product_id = m.product_id)
- order by p.product_name" {
+ order by p.product_name limit :how_many offset :start_row" {
+ append products "
+
+ [expr $count + 1] |
+ $product_name |
+
+
+ |
+ $one_line_description |
+ [ec_price_line $product_id $user_id $offer_code] |
+
"
- if { $count >= $start && [expr $count - $start] < $how_many } {
-
- append products "
-
- [expr $count + 1] |
- $product_name |
-
-
- |
- $one_line_description |
- [ec_price_line $product_id $user_id $offer_code] |
-
"
- }
incr count
- if { $count > [expr $start + (2 * $how_many)] } {
- # we know there are at least how_many more items to display next time
- set have_how_many_more_p t
- break
- } else {
- set have_how_many_more_p f
- }
}
+
+if { $product_count > [expr $start_row + (2 * $how_many)] } {
+ # we know there are at least how_many more items to display next time
+ set have_how_many_more_p t
+} else {
+ set have_how_many_more_p f
+}
+
if {[string equal $products ""]} {
set products ""
} else {
append products "
"
}
-if { $start >= $how_many } {
- set prev_link "Previous $how_many"
+if { $start_row >= $how_many } {
+ set prev_link "Previous $how_many"
} else {
set prev_link ""
}
if { $have_how_many_more_p == "t" } {
- set next_link "Next $how_many"
+ set next_link "Next $how_many"
} else {
- set number_of_remaining_products [expr $count - $start - $how_many]
+ set number_of_remaining_products [expr $product_count - $start_row - $how_many]
if { $number_of_remaining_products > 0 } {
- set next_link "Next $number_of_remaining_products"
+ set next_link "Next $number_of_remaining_products"
} else {
set next_link ""
}