Jump to content

[Solved] Import vouchers directly into database


Recommended Posts

HI,
I would like to create 1000 vouchers for groupon. However since these vouchers are like cash value, i do not want to enter sequential numbers.

Ive used excel to randomly generate numbers and would like to import them directly into the database ..... than entering 1000 vouchers individually (pls dont make me do that)

Im sure these is a way to directly import them into the database, if someone can just tell me the fields, that would be awesome.

Thanks

Link to comment
Share on other sites

Ive figured 75%, still working on the remaining 25%. Here are my steps:

1) Log into PHP MySQL Admin
2) Goto table "ps_discount"
3) Select Import tab
4) Browse to your csv file location
5) Important to set field separator etc values to csv values
6) In csv Also important to set date field format to the correct format (yyyy/mm/dd hh:mm:ss)
7) In csv, ensure you fill all the fields (to see all fields, you can export the table as csv with column headers)
8) After import, check to make sure everything has imported (pls import only 2 rows as test, before you import all)
9) Next goto table "ps_discount_category"
10) Import in same way the relevant categories for each voucher

Yes these steps seem like what you need to do, however i have not imported the last 2 steps (9, 10) will do so tonite and let you all know how it works out. In theory it should work.

Cheers and keep on Presta-shopping !!!

Link to comment
Share on other sites

Okay this is 100% solved, here are the steps i used to insert 300 vouchers at one time. Total time it took was 15 minutes.

Tables to be altered in phpMysql

1) ps_discount

2) ps_discount_lang

3) ps_discount_category

Steps for ps_discount

(id_discount id_discount_type behavior_not_exhausted id_customer id_group id_currency name value quantity quantity_per_user cumulable cumulable_reduction date_from date_to minimal active cart_display date_add date_upd)

1 in a csv file, create and update values for above fields

2 note: id_discount is the primary reference key for the other tables, so please keep track of it

3 note: for the date, the format is yyyy:mm:dd hh:mm:ss (if it is not properly set, the import will have issues)

4 next goto import (in table ps_discount), browse to your csv file and select it

5 change the options for csv (fields terminated by "," and fields enclosed by "leave blank"

6 click import and you are done

Steps for ps_discount_lang

(id_discount id_lang description)

- in a csv file update the values for the above fields

- note id_discount should be the exact same values copied from the ps_discount csv file

- follow the same steps as above (4, 5, 6)

Steps for ps_discount_category

(id_category id_discount)

-in a csv file update the values for the above fields

- note id_category are the category numbers for all the categories you want the voucher to be active in

- note id_discount should be the exact same values copied from the ps_discount csv file

- follow the same steps as above (4,5,6)

And thats it, you are done.

Enjoy !!

Link to comment
Share on other sites

  • 2 months later...

Hi Saray,

I've imported 1000 vouchers for Groupon and it worked perfectly. It did not effect my loyalty voucher module which I have running concurrently. (with cronjob)

 

Important point to note: Make sure the date field is formatted properly as mentioned above, else it will not work. Also first import only 2 vouchers to make sure all fields are being imported properly. Then do the remaining 998.

 

Cheers and good luck !

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 weeks later...

Hi Edzai,

 

Attached is one excel file, which has the 3 tables in it. Note, the best way to understand these tables will be to actually export your current tables with their column headers from phpMyadmin.

 

Also if you are using this, check out the second part to this process, here http://www.prestasho...961#entry670961

 

Hope these help you

Cheers

 

sorry guys for some reason it will not upload my csv file :(

Mods any ideas ?

uploaded a pdf file for now ;-)

Import voucher tables.pdf

Link to comment
Share on other sites

Can anyone see what is wrong with these csv files?!

 

I keep on getting an error message when I go to import them?!

 

I have added id_discount 6............

 

 

Not getting error message now, but voucher has invalid date in backend?

 

I just copied the dates format from the first entry done manually via prestashop back-end!?

csv .zip

Link to comment
Share on other sites

You need to correct the date format in ps_discount file to yyyy:mm:dd hh:mm:ss your current format has slashes.

 

Once you have created the required format in the csv, save the file, do not close it while uploading. Sometimes when you close the file and upload, it changes the format of the date field.

 

Everything else looks good. To retry the same import, you will need to delete your previous imported data.

Good luck!

Link to comment
Share on other sites

  • 4 months later...
  • 3 months later...
  • 3 months later...

Why do You need to import Groupon vouchers into the database? The question might be dumb, but I am from Bulgaria and I would like to know the point? You sell on Groupon and after that they come to Your shop and put an order there, or...?

 

 

Thank You in advance.

Link to comment
Share on other sites

  • 6 months later...

Hi,

i have a question, I did everything you wrote correctly. Then I wanted to open my website and received the message "Link to database cannot be established." Have no idea what happened. Can you help me, please?

 

 

Thanks in advance

Olga

Edited by nola_be (see edit history)
Link to comment
Share on other sites

Hi nola_be, these instructions are about 2 years old for a much older version of PrestaShop. They would not work for the later versions of PrestaShop because the database structure have changed. You can use this module to do this fast and efficiently, http://addons.prestashop.com/en/administration-tools-prestashop-modules/5592-import-voucher-from-csv.html

Link to comment
Share on other sites

The problem is now: how can I come back to the previous version of my website? It doesn't work.

 

I know, the topic is old, I have a 1.4 version of prestashop, so I thought it would be ok. Now I know it's not.

I've deleted files I've imported but nothing happened.

Link to comment
Share on other sites

im checking it with nola_be :) i think that the problem is related to the password (she changed it in webhosting control panel and forgot to change it in the configuration file)

 

i suppose that the problem is related to this, tommorow I will know more (here in europe is very late now)

 

 

edit:

as i said, the problem was related to password change, now everything works like a charm B)

Link to comment
Share on other sites

  • 3 weeks later...
  • 6 months later...

In Prestashop 1.5 you will need to work only with ps_cart_rule and ps_cart_rule_lang tables. 

Mechanism is even simplier:

0) create one cart rule in admin panel of your site with needed options.

1) go to ps_cart_rule in your phpMyAdmin.

2) select "export" tab and export that table as .csv file.

3) open exported file in Exel or OpenOffice Calc.

note: in Calc i used RANDBETWEEN function to create exclusive codes. You have to watch for repeating codes also. The best way is to insert =COUNTIF(J$3:J4;J4)  function somewhere in empty column ("description" for me). If it returns number greater than 1, you better simply delete that whole line.

4) make as many copies of your rule as you need. 

5) save new .csv file

6) go to "import" tab in phpMyAdmin and upload your new .csv

note: you will have to change you delimiter to ;

 

The only thing, in new cart rules tab "name" will be empty. For naming your rules, take ps_cart_rule_lang table. Edit it in a similar way as written above.

That's it!

Edited by Itinerant (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 1 month later...
×
×
  • Create New...