User Tools

Site Tools


ugiftcert-3:import

Importing certificates

With this feature it is possible to import pre-created certificates into the system.

Using import

Import page can be reached via Customers→Gift Certificate Import

Menu

The page itself is very simple to use. You can edit your settings and save them, or you can edit and click 'Save and Import' button to perform the import. Simply clicking that button without any changes will result in an import in case that the file you have inputted exists. Files used for import should be in CSV format (Comma Separated Values). This format represents plain text files where first row gives column names and every next row gives column values. Fields are separated by separator character and optionally surrounded with enclosure character. By default separator is comma (,) and enclosing character is double quote (“). You can change this on import page.

Import Page

Settings that you can change are:

  1. CSV field delimiter - this is field separator character
  2. CSV field enclosure - this is enclosure character, you may omit it if the field text does not contain the separator character
  3. CSV file name - file name of the file to be used for import. You have the option to upload many import files, either to create new certificates or update existing ones. With this option you can choose which of the uploaded files to import.
  4. When importing allow only: - this field allows to choose whether to only create new certificates (you can simply add your new data to existing file), only update existing certificates or do both.

Bellow settings form is an upload widget, the same as the one used to upload product images. It allows you to select multiple files to upload, which can be time saver. The widget is set to allow filtering by file type (.txt and .csv files) which will help if you have to look for import files in a big folder with many files in it. It also allows only txt and csv file types to be actually saved to server. Files are saved in var/ugiftcert/import folder of the website. As for any other Magento installation you should make sure that var/ folder is writable by web-server.

Uploaded file

When you click Save and Import button, the file name you entered is looked up and if it exists, import is made. This means that you don't have to use on page widget for uploads, you can do this via FTP or any other means you want. After clicking the button you don't need to do anything else but wait for the import to finish. How long would that be depends on the number of certificates that you import. Our test imports showed good creation and update rate.

Import Result

If you have very great numbers to import, it might be good idea to separate import files to smaller size files which will be easier on your server memory consumption.

Allowed fields

  • cert_number - code of certificate. When certificates are created this is used as is, patterns are not taken in consideration. This is the only required field, it is used for certificate look-up when updating certificates;
  • pin - PIN number, also no patterns considered, used literally as provided. If omitted null is used;
  • balance - certificate amount. Should be a numeric value. If no value is given or it is not numeric then 0 is used;
  • expire_at - expiration date - should be a string parse-able by strtotime function. Some examples here;
  • currency_code - currency used for certificate - should be three character currency code as accepted by Magento. If empty or non valid value is provided, default store currency is used.;
  • store_id - store id for which certificate is valid - should be a number representing store id or store code. If empty value is given, then current store id is used;
  • status - certificate status. Should be a string one of - active or A, pending or P, inactive or I. Lower or upper case is not important. If empty or non valid value is provided, status is set to Inactive;
  • sender_name - sender name, string. If empty it is set to null;
  • recipient_name - recipient name, string. If empty it is set to null;
  • recipient_email - recipient email, string. If empty it is set to null;
  • recipient_address - recipient address, string. If empty it is set to null;
  • recipient_message - recipient message, string. If empty it is set to null;
  • comments - creation or update comment, string. If empty it is set to null;
  • conditions_serialized - you can also import certificate conditions, but they have to be in PHP serialized format, which makes them hard to manually edit. This is useful if you can copy conditions that you like from database and use them to mass update or add certificate conditions.

NOTE: about date formats

Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

Example:

sample.csv
"cert_number","pin","balance","expire_at","currency_code","store_id","status","sender_name","recipient_name","recipient_email","recipient_address","recipient_message","comments"
"A0002","1001","26","8.09.2012","USD","1","Active","Myself","Test User","test@email.com","123 Some Street","Cheers","Some comment"
"A0003","1002","27","8.10.2012","USD","","Active","","","","","",""
"A0004","1003","28","8.11.2012","USD","1","P","","","","","",""
"A0005","1004","29","8.12.2012","USD","1","i","","","","","",""
ugiftcert-3/import.txt · (external edit)