Index: openacs-4/packages/ecommerce/www/admin/products/categories-upload-2-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/products/categories-upload-2-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/ecommerce/www/admin/products/categories-upload-2-postgresql.xql 24 Nov 2001 03:44:26 -0000 1.1
@@ -0,0 +1,73 @@
+
+
\n"
+ # Check if there is a product with the give sku.
+ # Set product_id to NULL if there is no
+ # product with the given sku.
+ set product_id [db_string product_check {select product_id from ec_products where sku = :sku;} -default ""]
+
+ # Match the product with the given (sub)category.
+ if { $product_id != "" } {
+
+ # see if this matches any subcategories
+ set submatch_p 0
+ db_foreach subcategories_select "
+ select c.category_id, c.category_name, s.subcategory_id,
+ s.subcategory_name from ec_subcategories s, ec_categories c
+ where c.category_id = s.category_id
+ and upper(:category) like upper(subcategory_name) || '%'" {
+ set submatch_p 1
+
+ # add this product to the matched subcategory
+ set sql "insert into ec_subcategory_product_map (product_id, subcategory_id, publisher_favorite_p, last_modified, last_modifying_user, modified_ip_address) values (:product_id, :subcategory_id, 'f', sysdate, :user_id, :ip)"
+ if { [catch {db_dml subcategory_insert $sql} errmsg] } {
+ #error, probably already loaded this one
+ } else {
+ doc_body_append "Matched $category to subcategory $subcategory_name in category $category_name
\n"
+ }
+ # now add it to the category that owns this subcategory
+ set sql "insert into ec_category_product_map (product_id, category_id, publisher_favorite_p, last_modified, last_modifying_user, modified_ip_address) values (:product_id, :category_id, 'f', sysdate, :user_id, :ip)"
+ if { [catch {db_dml unused_sub $sql} errmsg] } {
+ #error, probably already loaded this one
+ }
}
- # now add it to the category that owns this subcategory
- set sql "insert into ec_category_product_map (product_id, category_id, publisher_favorite_p, last_modified, last_modifying_user, modified_ip_address) values (:product_id, :category_id, 'f', sysdate, :user_id, :ip)"
- if { [catch {db_dml unused_sub $sql} errmsg] } {
- #error, probably already loaded this one
- }
- }
- # see if this matches any categories
- set match_p 0
- db_foreach category_match_select "select category_id, category_name from ec_categories where upper(:category) like upper(category_name) || '%'" {
- set match_p 1
- set sql "insert into ec_category_product_map (product_id, category_id, publisher_favorite_p, last_modified, last_modifying_user, modified_ip_address) values (:product_id, :category_id, 'f', sysdate, :user_id, :ip)"
- if { [catch {db_dml cateogry_insert $sql} errmsg] } {
- #error, probably already loaded this one
+ # see if this matches any categories
+ set match_p 0
+ db_foreach category_match_select "select category_id, category_name from ec_categories where upper(:category) like upper(category_name) || '%'" {
+ set match_p 1
+ set sql "insert into ec_category_product_map (product_id, category_id, publisher_favorite_p, last_modified, last_modifying_user, modified_ip_address) values (:product_id, :category_id, 'f', sysdate, :user_id, :ip)"
+ if { [catch {db_dml category_insert $sql} errmsg] } {
+ #error, probably already loaded this one
+ } else {
+ doc_body_append "Matched $category to category $category_name
\n"
+ }
+ }
+ if { ! ($match_p || $submatch_p) } {
+ doc_body_append "Could not find matching category or subcategory for $category
\n"
} else {
- doc_body_append "Matched $category to category $category_name
\n"
+ incr success_count
}
}
- if { ! ($match_p || $submatch_p) } {
- doc_body_append "Could not find matching category or subcategory for $category
\n"
- } else {
- incr success_count
- }
}
if { $success_count == 1 } {
Index: openacs-4/packages/ecommerce/www/admin/products/categories-upload.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/products/categories-upload.tcl,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/products/categories-upload.tcl 20 Apr 2001 20:51:14 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/products/categories-upload.tcl 24 Nov 2001 03:41:06 -0000 1.2
@@ -6,10 +6,10 @@
The file format should be:
- product_id_1, category_description_1
- product_id_2, category_description_2
+ sku_1, category_description_1
+ sku_2, category_description_2
...
- product_id_n, category_description_n
+ sku_n, category_description_n
Where each line contains a product id, category name pair. There may
be multiple lines for a single product id which will cause the
@@ -66,10 +66,10 @@
The file format should be:
-product_id_1, category_description_1
-product_id_2, category_description_2
+sku_1, category_description_1
+sku_2, category_description_2
...
-product_id_n, category_description_n
+sku_n, category_description_n
Where each line contains a product id, category name pair. There may be multiple lines for a single product id