ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Mass import of parent categories and child categories

November 22, 2011 8:17am

Subscribe [4]
  • #1 / Nov 22, 2011 8:17am

    EnergyFreak

    102 posts

    Hi,

    I would like to know how I can mass import some categories into EE. My category hierarchy will be as followed:

    Parent cat 1 -> Subcat 1 -> Subcat 2 -> Subcat 3
    Parent cat 2 -> Subcat 1 -> Subcat 2 -> Subcat 3
    etc.

    ex:

    University 1
    Faculty 1
    Department 1
    Subject 1

    Can this be done via an excel sheet or something?

    Thanks.

  • #2 / Nov 22, 2011 3:00pm

    If your host offers a tool like PHPMyAdmin on the backend then an Excel file or CSV will work. We have done it a number of times. The key will be matching up everything just right if you want a single import. Your parent_ids as well as cat_ids will need to be set manually. Just take a look at the exp_categories table, it is pretty basic. Make sure to back up the table before you try anything. Once you get into it if you have any questions feel free to hit me up.

  • #3 / Nov 22, 2011 4:09pm

    EnergyFreak

    102 posts

    Yes my host supports PHPMyadmin. Do you have any idea how I would write the sql query to mass import? Also, how would I set them up in my excel sheet?

    Thanks.

  • #4 / Nov 23, 2011 5:05am

    GDmac - expocom

    350 posts

    Have you made a sample category group with some sample parent/child categories and looked at the mysql table?
    If you export them with PHPMyAdmin as CSV and import it into Excel to get an idea of how it is structured.

    - If an item is in the root of the tree then parent_id is 0 otherwise it is the cat_id of another category it belongs under.
    - cat_id, is a unique_id database field, so you have to find out the latest value and start your cats from there.
    - Setup the category group beforehand and take note of the group_id
    - cat_order starts over for every new sub-level

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases