1

ive looked through the current related questions but have not managed to find anything similar to my needs.

Im in the process of creating a affiliate store using zencart - now one of the issues is that zencart is not designed for redirects and affiliate stores but it can be done. I will be changing the store so it acts like a showcase store showing prices.

There is a mod called easy populate which allows me to upload datafeeds. This is all well and good however my affiliate link will not be in each product. I can do it manually after uploading the data feed and going to each product and then adding it as an image with a redirect link - However when there are over 500 items its going to be a long repetitive and time consuming job.

I have been told that I can add the links to the data feed before uploading it to zencart and this should be done using python. Ive been reading about python for several days now and feel im looking for the wrong things. I was wondering if someone could please advise the simplest way for me to get this done.

I hope the question makes sense

thanks

abs

abs
  • 11
  • 2
  • 1. Could you add an example record of your CSV, and how you would like the record to look after transformation, just before upload? Than we would be better able to give you an appropriate code snippet. 1. And, do all records need to be changed, or do some records already have the link? – extraneon Mar 27 '10 at 12:40

2 Answers2

2

You could craft a python script using csv module like this:

>>> import csv
>>> cartWriter = csv.writer(open('yourcart.csv', 'wb'))
>>> cartWriter.writerow(['Product', 'yourinfo', 'yourlink'])

You need to know how link should be formatted hoping that it could be composed using the other parameters present on csv file.

systempuntoout
  • 71,966
  • 47
  • 171
  • 241
  • im still waiting to recieve the csv but I will need to add it in a format so that zencart will pick it up. i have a sample file of what i should be aiming for which came with the easy populate module.But i dont know how to upload it here so i will give a link. it can be downloaded from here http://buycheaplcdtvs.com/Full-EP2010Mar27-0707.csv please note that there is no data in the file however it has all the categories needed - hope this is what you are asking for thanks – abs Mar 27 '10 at 13:31
0

First, use the CSV module as systempuntoout told you, secondly, you will want to change your header to:

mimetype='text/csv'
Content-Disposition = 'attachment; filename=name_of_your_file.csv'

The way to do it depends very much of your website implementation. In pure Python you would probably do that with an HttpResponse object. In django, as well, but there are some shortcuts.

You can find a video demonstrating how to create CSV files with Python on showmedo. It's not free however.

Now, to provide a link to download the CSV, this depends of your Website. What is the technology behinds it : pure Python, Django, Pylons, Tubogear ?

If you can't answer the question, you should ask your boss a training about your infrastructure before trying to make change to it.

Bite code
  • 578,959
  • 113
  • 301
  • 329
  • wow - sounds so technical - i dont think i will be able to do it- i didnt understand what you guys are saying but i guess thats because im a total newbie to python -would there be any video tutorials you could point me to – abs Mar 27 '10 at 13:25
  • Yes, programming is technical, that's why this website is full of questions :-) Added a link to a video in the question. – Bite code Mar 27 '10 at 14:03