Index: openacs-4/packages/ecommerce/www/admin/products/import-images-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/products/import-images-2.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ecommerce/www/admin/products/import-images-2.tcl 21 Feb 2005 12:10:41 -0000 1.1.2.1 @@ -0,0 +1,214 @@ +# www/[ec_url_concat [ec_url] /admin]/products/import-images-2.tcl +ad_page_contract { + + @author Torben Brosten + @creation-date 20-02-2005 + @cvs-id $Id: import-images-2.tcl,v 1.1.2.1 2005/02/21 12:10:41 torbenb Exp $ +} { + csv_file + csv_file.tmpfile:tmpfile + file_type + delimiter +} + +# We need them to be logged in + +ad_require_permission [ad_conn package_id] admin +set user_id [ad_get_user_id] +set peeraddr [ns_conn peeraddr] + +# Grab package_id as context_id + +set context_id [ad_conn package_id] + +doc_body_append "[ad_admin_header "Uploading Products"] + +
Error!Image update of $sku failed with error:<\p>
$errmsg
" + } else { + doc_body_append "Imported images for product: $sku
" + # A product row has been successfully processed, increase counter + incr success_count + } + # create a thumbnail + if { $use_both_param_dimensions } { + set convert_dimensions "${thumbnail_width}x${thumbnail_height}>" + } else { + if { $thumbnail_width_is_blank } { + if { $thumbnail_height_is_blank } { + set convert_dimensions "100x10000" + } else { + set convert_dimensions "10000x${thumbnail_height}" + } + } else { + set convert_dimensions "${thumbnail_width}x10000" + } + } + + set perm_thumbnail_filename [file join $full_dir_path "product-thumbnail.jpg"] + + if [catch {exec $convert -geometry $convert_dimensions -comment \"$image_comment\" $product_image_location $perm_thumbnail_filename} errmsg ] { + doc_body_append "Error! Could not create thumbnail for product: $sku Error is: $errmsg
" + } + + } else { + + # Let them know this sku is not in the catalog + doc_body_append "FAILURE!Could not import image for sku: $sku, because sku was not found in catalog." + } + } + } + + # read next line of data file, depending on file type, or end read loop if error. + if {[string eq $file_type "csv"]} { + set line_status [ns_getcsv $datafilefp elements] + } elseif {[string eq $file_type "tab"]} { + set line_status [ec_gets_char_delimited_line $datafilefp elements] + } elseif {[string eq $file_type "delim"]} { + set line_status [ec_gets_char_delimited_line $datafilefp elements $delimiter] + } else { + # no valid filetype chosen + set line_status -1 + } + +} + +if { $success_count == 1 } { + set product_string "product image and thumbnail" +} else { + set product_string "product images and thumbnails" +} + +doc_body_append "Successfully imported $success_count $product_string out of [ec_decode $count "0" "0" [expr $count -1]]. + +[ad_admin_footer] +" Index: openacs-4/packages/ecommerce/www/admin/products/import-images.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/products/import-images.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ecommerce/www/admin/products/import-images.tcl 21 Feb 2005 12:10:41 -0000 1.1.2.1 @@ -0,0 +1,79 @@ +# www/[ec_url_concat [ec_url] /admin]/products/import-images.tcl +ad_page_contract { + This page uploads a data file containing store-specific + product references and new product images pathnames + for bulk importing images and thumbnails into ecommerce. + The file format should be: + + field_name_1, field_name_2, ... field_name_n + value_1, value_2, ... value_n + + where the first line contains the actual names of the columns in + ec_products and the remaining lines contain the values for the + specified fields, one line per product. + + Legal values for field names are the columns in ec_products (see + ecommerce/sql/ecommerce-create.sql for current column names): + + sku + image_pathname + + Note: product_id, dirname, creation_date, available_date, last_modified, + last_modifying_user and modified_ip_address are set automatically + and should not appear in the data file. + + @author Torben Brosten (torben@kappacorp.com) + @creation-date Spring 2005 + @cvs-id $Id: import-images.tcl,v 1.1.2.1 2005/02/21 12:10:41 torbenb Exp $ +} { +} + +ad_require_permission [ad_conn package_id] admin + +doc_body_append "[ad_admin_header "Bulk Import Product Images"] + +
+ + + +++ +Notes: +
+ ++ + This page uploads a data file containing product information to bulk import product images into the catalog. The file format should be: +
+
++field_name_1, field_name_2, ... field_name_n
+
+value_1, value_2, ... value_n+ where the first line contains the actual names of the columns and + the remaining lines contain the values for the specified fields, one line per product. +
+
+ sku and image_fullpathname are the only fields used. All other field names and values are ignored. sku should contain product sku values. image_fullpathname should contain absolute file references, one per sku. For example a value for image_fullpathname might look like: /var/tmp/boots/sidekick-3000.jpg +
++ +[ad_admin_footer] +" Index: openacs-4/packages/ecommerce/www/admin/products/upload-utilities.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/products/upload-utilities.tcl,v diff -u -N -r1.4.2.2 -r1.4.2.3 --- openacs-4/packages/ecommerce/www/admin/products/upload-utilities.tcl 17 Feb 2005 21:21:49 -0000 1.4.2.2 +++ openacs-4/packages/ecommerce/www/admin/products/upload-utilities.tcl 21 Feb 2005 12:10:41 -0000 1.4.2.3 @@ -49,14 +49,15 @@ creates the product-categories mappings by finding exact matches to the category tables' indexes category_id, subcategory_id, subsubcategory_id.
- +