Author Topic: Adding Excel File Upload option to product_csv module  (Read 252569 times)

Joseph Kwan

  • Advanced
  • Hero Member
  • *****
  • Posts: 2344
Adding Excel File Upload option to product_csv module
« on: April 04, 2007, 01:53:57 am »
I have added an excel file upload option to the product csv module making use of the open source PHP-ExcelReader. Most of the csv upload settings apply to this option. The only difference is the file is an .xls file and no limiters are needed. Anyone interested can download the hacked files at

http://www.expertcms.net/public_downloads/hack_Virtuemart_xls_upload.zip

Installation instructions included in the package.

IMPORTANT! Do remember to backup your files and database before hacking and testing.

UPDATED VERSION AVAILABLE at http://forum.virtuemart.net/index.php?topic=27154.msg94338#msg94338

 
Joomla/VM Upgrade Services. Problems with your migration? We can help.
Custom extensions to VM. Performance Tuning. Template modifications and advices.
Pay service to make VM work according to your needs. Your Joomla/VM solutions are just a PM away.

Ronald

  • Beginner
  • *
  • Posts: 34
Re: Adding Excel File Upload option to product_csv module
« Reply #1 on: April 07, 2007, 18:50:26 pm »
Looks nice dude, I'm testing it now and it seems it works. I think many peops will like this hack!

EyeScream

  • Beginner
  • *
  • Posts: 39
Re: Adding Excel File Upload option to product_csv module
« Reply #2 on: April 30, 2007, 15:58:43 pm »
Wow!
Damn... This is a serious timesaver!
I usually do the following, when importing products:
1, I import my CSV file into Excel, modify it to suit my needs and save it as an Excel file.
2, I open the Excel file in Open Office (to be able to export with custom delimiters).
3, I export the file to a CSV file and import it into VM.

Now, I just save the file as an Excel file and import it! Sweet!

This hack should be getting a first class ticket into the next release of VM!

Ok... Gotta go... I´m running out of exclamation marks...
 ;D

Thanks, Joseph!

/..EyeScream

pcinvent

  • Beginner
  • *
  • Posts: 19
    • PCinvent Studio
Re: Adding Excel File Upload option to product_csv module
« Reply #3 on: April 30, 2007, 20:57:56 pm »
Fantastic hack. Highly Recommend to be integrated into standard VirtueMart Packages!!! ;)

pcinvent

  • Beginner
  • *
  • Posts: 19
    • PCinvent Studio
Re: Adding Excel File Upload option to product_csv module
« Reply #4 on: April 30, 2007, 21:32:18 pm »
In the English.php language file, the varible of  $_PHPSHOP_PRODUCT_CSV_UPLOAD are duplicated.
It will generated the error.
Please check and correct the  file for this line:
var $_PHPSHOP_PRODUCT_CSV_UPLOAD = 'CSV/Excel File upload';

pcinvent

  • Beginner
  • *
  • Posts: 19
    • PCinvent Studio
Re: Adding Excel File Upload option to product_csv module
« Reply #5 on: April 30, 2007, 21:40:55 pm »
Error shows after Upload. Doesn't work!
"Error: Mime type not accepted. Type for file uploaded: application/x-msexcel"
 ???

Joseph Kwan

  • Advanced
  • Hero Member
  • *****
  • Posts: 2344
Re: Adding Excel File Upload option to product_csv module
« Reply #6 on: May 01, 2007, 06:32:06 am »
The duplicate var does not generate error at least in my version of PHP. I think it is better to put all the language in one place. Go ahead to delete the duplicate entry if it caused problem for you.

Please add the line
    'application/x-msexcel',
to line 1152 in ps_csv.php if you have mime type problem.


Cheers,
Joseph
Joomla/VM Upgrade Services. Problems with your migration? We can help.
Custom extensions to VM. Performance Tuning. Template modifications and advices.
Pay service to make VM work according to your needs. Your Joomla/VM solutions are just a PM away.

workerb

  • Beginner
  • *
  • Posts: 9
Re: Adding Excel File Upload option to product_csv module
« Reply #7 on: May 09, 2007, 07:08:01 am »
I followed the instructions and when I went to upload the xls file I recieved an error:
Error: File Extension not allowed. Valid extensions are: csv, txt

I am using Regular upload and "use column headers as configuration" and I upload from my HD.

I'm not sure what to do next or how to trouble shoot this.

Thanks

Joseph Kwan

  • Advanced
  • Hero Member
  • *****
  • Posts: 2344
Re: Adding Excel File Upload option to product_csv module
« Reply #8 on: May 09, 2007, 07:29:33 am »
Make sure the file class/ps_csv.php is replaced. Lines 1139-1142 of this file should be

      $allowed_suffixes_arr = array(
      0=> 'csv'
      ,1 => 'txt'
      ,2 => 'xls'
      // add more here if needed
      );

Joseph
Joomla/VM Upgrade Services. Problems with your migration? We can help.
Custom extensions to VM. Performance Tuning. Template modifications and advices.
Pay service to make VM work according to your needs. Your Joomla/VM solutions are just a PM away.

groentjie

  • Jr. Member
  • **
  • Posts: 87
Re: Adding Excel File Upload option to product_csv
« Reply #9 on: May 09, 2007, 09:38:19 am »
I have installed the hack but now if I go to VM is shows this

what's wrong?

Joseph Kwan

  • Advanced
  • Hero Member
  • *****
  • Posts: 2344
Re: Adding Excel File Upload option to product_csv module
« Reply #10 on: May 09, 2007, 18:26:28 pm »
Looks like you are having problem with the language file. Try comment out line 1887 of language/english.php. Let me know this solves the problem and also your OS and php version.

Joseph
Joomla/VM Upgrade Services. Problems with your migration? We can help.
Custom extensions to VM. Performance Tuning. Template modifications and advices.
Pay service to make VM work according to your needs. Your Joomla/VM solutions are just a PM away.

groentjie

  • Jr. Member
  • **
  • Posts: 87
Re: Adding Excel File Upload option to product_csv module
« Reply #11 on: May 09, 2007, 21:55:00 pm »
in my english.php it looks like this:

1885 /*
1886   Customized language for XLS upload
1887 */
1888   var $_PHPSHOP_PRODUCT_CSV_UPLOAD = 'CSV/Excel File upload';
1889   var $_PHPSHOP_CSV_FILE_FORMAT = 'File Upload Format';

What line needs to be commented out?

Joseph Kwan

  • Advanced
  • Hero Member
  • *****
  • Posts: 2344
Re: Adding Excel File Upload option to product_csv module
« Reply #12 on: May 09, 2007, 21:59:11 pm »
line 1888
Joomla/VM Upgrade Services. Problems with your migration? We can help.
Custom extensions to VM. Performance Tuning. Template modifications and advices.
Pay service to make VM work according to your needs. Your Joomla/VM solutions are just a PM away.

groentjie

  • Jr. Member
  • **
  • Posts: 87
Re: Adding Excel File Upload option to product_csv module
« Reply #13 on: May 09, 2007, 22:15:05 pm »
Ok, I added the dutch language in VM, because that was my default language in the normal site. So the first error is gone, but when I press csv then this error appears:

* Checks the field for existing value, if not set the default value if allowed */ function ValidateCSVInput($fieldname) { global $data, $ps_csv; if (isset($ps_csv->csv_fields[$fieldname])) { if (!empty($data[$ps_csv->csv_fields[$fieldname]["ordering"]-1])) { $this->$fieldname = trim($data[$ps_csv->csv_fields[$fieldname]["ordering"]-1]); } else if (!$ps_csv->skip_default_value) { $this->$fieldname = $ps_csv->csv_fields[$fieldname]["default_value"]; } } } function get_product_type_id() { $db = new ps_DB; $q = "SELECT product_type_id FROM #__{vm}_product_type "; $q .= "WHERE product_type_name='".$this->product_type_name."' "; $db->query($q); $this->product_type_id = $db->f("product_type_id"); } function get_product_type_name() { $this->ValidateCSVInput("product_type_name"); } function get_product_type_parameter_name() { $this->ValidateCSVInput("product_type_parameter_name"); } function get_product_type_parameter_label() { $this->ValidateCSVInput("product_type_parameter_label"); } function get_product_type_parameter_description() { $this->ValidateCSVInput("product_type_parameter_description"); } function get_product_type_parameter_type() { $this->ValidateCSVInput("product_type_parameter_type"); } function get_product_type_parameter_old_type() { $db = new ps_DB(); if ($this->product_type_parameter_name) { $q = "SELECT parameter_type FROM #__{vm}_product_type_parameter "; $q .= "WHERE parameter_name='".$this->product_type_parameter_name."' "; $q .= "AND product_type_id = ".$this->product_type_id; $db->query($q); $this->product_type_parameter_old_type = $db->f("parameter_type"); } } function get_product_type_parameter_values() { $this->ValidateCSVInput("product_type_parameter_values"); } function get_product_type_parameter_multiselect() { $this->ValidateCSVInput("product_type_parameter_multiselect"); } function get_product_type_parameter_default() { $this->ValidateCSVInput("product_type_parameter_default"); } function get_product_type_parameter_unit() { $this->ValidateCSVInput("product_type_parameter_unit"); } function get_product_type_parameter_list_order() { $this->ValidateCSVInput("product_type_parameter_list_order"); if ($this->product_type_id) { $db = new ps_DB; $q = "SELECT parameter_list_order FROM #__{vm}_product_type_parameter "; $q .= "WHERE product_type_id=".$this->product_type_id." "; $q .= "AND parameter_name = '".$this->product_type_parameter_name."'"; $db->query($q); $this->product_type_list_order = $db->f("parameter_list_order"); } } } ?>

Joseph Kwan

  • Advanced
  • Hero Member
  • *****
  • Posts: 2344
Re: Adding Excel File Upload option to product_csv module
« Reply #14 on: May 09, 2007, 22:55:46 pm »
Do you make it work for English? I think it's better to make sure it works with English before trying other language.

Joseph
Joomla/VM Upgrade Services. Problems with your migration? We can help.
Custom extensions to VM. Performance Tuning. Template modifications and advices.
Pay service to make VM work according to your needs. Your Joomla/VM solutions are just a PM away.