A new website build for FreshPoint (Sysco) including a one way ongoing feed of produce items from a source database into WordPress.
Built in WordPress CMS. Otherwise everything is custom.
Data needed to feed in to this database from another website. Then when an item is updated, deleted or created on the source website, data on the new website had to follow suit. There was no regular CMS on the source website so I couldn’t just fall back on a rest api.
The data feed was accomplished by creating a function on the source website that retrieves data from the source database and outputs it in xml format.
The source xml was connected to a cron job at regular intervals.
Then on the destination website I built a custom function to parse the source xml in incremental steps, keeping track of it’s position as it goes. It takes about an hour for it to traverse through all source products. It had to be done this way to minimize it’s footprint on the new website and keep it from impacting user experience.
It cleans the product data, matches it to the product post type on the destination website, and attempts to find a match. If a match is found it checks for updated content or image, and if necessary, updates the appropriate post and/or uploads the image to the media library, attaches the correct meta data, and sets it as the featured image of the correct post.
If the post ‘visibility’ has changed, it changes post visibility to match.
Besides this I had to allow for products on the website that aren’t coming in from the source. This was accomplished by using a specific type of slug for auto-generated posts, so that new posts created by site admins wouldn’t interfere or be affected by the feed’s actions.
Credits: This project was done while working for Savage Brands as Lead Web Developer. It was designed by Ashley Rundall.