WordPress.org

Ready to get started?Download WordPress

Forums

CSV Importer
what about other fields? (10 posts)

  1. hormiganegra
    Member
    Posted 1 year ago #

    I'm using bheadrik's version, and I would like to know if it is possible to use the plugin to import information that go to metaboxes created by other plugins.

    For example, I'm using Post Expirator. I thought I was very smart by including the field names in my csv and then uploading them, but it didn't work at all.

    Has anybody used the plugin to upload data for field that are not common post field or custom fields? If so, how did you do it? if not, how do you suggest I do it?

    Thanks

    http://wordpress.org/extend/plugins/csv-importer/

  2. bheadrick
    Member
    Posted 1 year ago #

    I'm pretty sure it says in the readme that any column names that don't start with "csv_" will be treated as meta fields. And yes, I've used this functionality extensively.

    have you checked the database and verified that the field names (meta_key) you're trying to use are the correct ones?

    Fields that begin with an underscore won't be visible in the "custom fields" section on the post, so if you want to be certain what the field names are, find a post that has the config you want to achieve, look in the address bar and note the post_id, then jump into phpmyadmin and run this query:

    select * from wp_postmeta where post_id = (your post id)

    now, look for the field that has the value you want, and note the meta_key. You may also notice that the value might be in a different format than what you had been using.

  3. hormiganegra
    Member
    Posted 1 year ago #

    Thanks for your response, it was very helpful. I did see the mention of columns starting with "csv_" but I hadn't used the right field names. Now with your explanation everything worked wonderfully!!!

    except for a field which is supposed to store a google maps link. using the query you suggested I saw that the actual content of that field is not a regular url link to GMaps but something like this:

    a:1:{s:10:"google_map";s:194:"https://maps.google.com/maps?q=Statue+of+Liberty,+New+York,+NY&hl=en&sll=40.697488,-73.979681&sspn=0.602839,1.234589&oq=statue+of+liberty&hq=Statue+of+Liberty,+New+York,+NY&radius=15000&t=m&z=13";}

    where the values for a, s, and the other s seem to change depending on the map link. I tried importing only the link but, of course, it did not work well (=at all), only when using whole string it gets imported properly. I'm having problems researching this also because I've got no idea what it could be called.

    So I cannot import data to this map field because I don't know how to deduce/find this additional data. Would you know how I can create this for a different map link, or where I can find more information about this and possibly (=remotely) figure it out?

    Thank you so much!

  4. bheadrick
    Member
    Posted 1 year ago #

    What you're looking at is called serialized data - it's an array of strings squashed down to a single string. I forked this plugin and added some additional features as well as fixing this serialization bug. You can get it here:

  5. hormiganegra
    Member
    Posted 1 year ago #

    I'm already using your forked version, but I don't seem to know how to make it work for this (or understand how it works, for that matter). How do I do it?
    Thanks again!!!

  6. bheadrick
    Member
    Posted 1 year ago #

    oh, I see what you mean.
    My version only preserves the serialized data, but it doesn't help you create it. I'll elucidate what is going on there:
    a:1 - I believe this indicates there's only one object in the array
    s:10 - the following string is 10 characters long
    s:194 - the following string is 194 characters long

    it looks like your only real variable is that last item, so what you could do in excel is have a field that has that map link (call it J2, and then in the gmaps column have

    =concatenate("a:1:{s:10:""google_map"";s:",len(J2),":""",J2,""";}")

  7. bheadrick
    Member
    Posted 1 year ago #

    I suppose it would also be feasible to add the ability to serialize data, but it would get pretty complicated if you wanted to have an array of objects on a single field (though usually, you only have one)

  8. bheadrick
    Member
    Posted 1 year ago #

    Ok, gave it some thought, because I regularly deal with a couple instances when importing WooCommerce products where serialized data is involved, and I invariably end up doing manual steps to get those values generated.
    I thought of a very usable way to implement serialized data. The column label will be the meta_key just as it is now, but in the field, serialized data will be formatted like this:
    google_map::https://maps.google.com/maps?q=Statue+of+Liberty...

    for fields with multiple objects, it would be

    key::value,key::value....

    Now to test...

  9. hormiganegra
    Member
    Posted 1 year ago #

    OH so that's what it is! Thanks for the explanation, now I can pull it off!

    Thanks a lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Good luck with the plugin

  10. bheadrick
    Member
    Posted 1 year ago #

    it works!
    the format is
    label1::value1[]label2::value2....

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.