We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17665
    • 54 Posts
    This module lets you create MODx pages using a csv file.
    --

    Although it can be used to create any kind of page, I wrote it today specifically for importing product pages for use with http://www.foxycart.com. You basically create a csv file of all the products you want to import into your site. The first row should be your field names from the site_content table or names of valid template variables. The script does some basic checking to ensure you are using valid template variables and that you have the basic required site_content fields of parent, template and pagetitle.

    1) Copy product_importer.php.txt and paste it into the contents of a new module named "Product Importer".
    2) Create a new csv file with all the products you want to import (see product_list.csv.txt as an example). I recommend using "|" as a field delimiter when you create the csv file.
    3) Upload your csv file to your server and run a chmod 777 on it so php can read it in.
    4) Modify "Product Importer" with the path to your csv file, run it and verify the SQL it’s about to run on your database.
    5) When you’re satisfied, modify the Product Importer and set $executeSql to true.
    6) Run Product Importer and watch the magic happen.
    7) Delete the csv file off your server and remove the Product Importer to avoid accidentally running it again.

    Unfortunately, I don’t really have the time to make this a real module... but I originally came up with the Doc Manager concept and Garry Nutting made that thing amazing so if anyone feels like doing the same here... go for it!

    Ideas for improvement:
    - make it not look like crap (i.e. integrate it with the correct language file and admin template styles).
    - provide a way to upload the csv file directly to the module.

    Note: to get the correct value for "template" in your csv file, mouse over the template you want under resources and use the number directly after "id=".


    The back story:
    Instead of working on FoxyCart on a Sunday afternoon, I decided to continue my pro bono work for http://globalsupportmission.com/ and their soon to be available http://www.secondavenuetrade.com/. If anyone is interested in helping orphans in Africa, check out GSM. These guys are seriously awesome. So anyway... I had like 80+ product pages with various template variables and such and I definitely didn’t feel like adding them by hand one by one. Hopefully this will help someone else in a similar situation.

    Feel free to reply and let me know what you think.
      • 17665
      • 54 Posts
      I feel kind of stupid... I thought I searched well before building this thing but just now found this post:
      http://modxcms.com/forums/index.php/topic,15347.0.html

      It sounds familiar so I probably saw it in my original search but wrote it off thinking it was just in Russian.