script to auto update/ import records

This topic contains 6 replies, has 2 voices, and was last updated by  Alex Rollin 6 years, 2 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #467196

    Pete Williams
    Full Member
    Post count: 34

    Hi Guys, I have a challenging question for you…

    AIM – Import a database of listings every night to replace all existing listings
    REASON – Our main database of members is held on one site, we then want to refresh and update a serious of feeder sites overnight every night (to account for new members and expired ones)

    Ideally we would do this via a cron job and MySQL – Empty the relevant tables, then populate them with the new data. If you have any experience with this then please share the script or notes

    Is there a list of which tables hold the listing info? (we don’t need to change any WP user info as the way we have constructed our sites is that all listings belong to one single user)

    If you can supply a list o the relevant tables, then we would aim to get the cron to empty those tables and then re-populate them with suitably formatted contents. In theory this should work right?

    Alternative option would be to have a cron empty the relevant tables, then we re-populate with a Mac Automator process, which will produce the CSV, go into the admin GUI and do a regular import, like you would under normal import situations. Bit more primitive this way, but should work fine if there’s no way to import using MySQL

    Any clues or tips please?

    Thanks!

    Pete

    #467278

    Pete Williams
    Full Member
    Post count: 34

    I had a feeling it was going to be a tough question without a quick or easy answer 😉

    #467298

    Alex Rollin
    Moderator
    Post count: 27815

    Great idea, to update sites.
    The way to do that is with the API. Build an app/script that GETs the updated listing and POSTs the updated data to another sites.

    https://wpgeodirectory.com/docs-v2/geodirectory/settings/api/

    Let us know if you have any questions about that

    #467424

    Pete Williams
    Full Member
    Post count: 34

    Thanks Alex!

    My techie colleague has been looking at this and is pretty positive this will do what we need, thanks!

    He has asked however if I can ask about ‘ideally any example to DELETE an ID (Listing) and also a basic PUT or Insert for a listing.

    Is this something you can point us to please?

    #467449

    Alex Rollin
    Moderator
    Post count: 27815

    It is ‘just an API’, and works ‘the WP way’, so, any example you find for WP, you just need to apply that to the GD routes.

    ex. https://www.pjvillanueva.com/wordpress-rest-api-using-postman/

    #467454

    Pete Williams
    Full Member
    Post count: 34

    AHA! That should give my colleague a good start, thanks Alex!

    This stuff is WAY above my pay grade, I stick to content and css 😉

    Once we crack it, we can share it if anyone is looking to do the same thing maybe

    #467462

    Alex Rollin
    Moderator
    Post count: 27815

    Nothing to crack, exactly. All the routes are declared. This is every day stuff for developers, now.

Viewing 7 posts - 1 through 7 (of 7 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount