Datafeedr API Customisation

The Datafeedr plugin reset product categories, after an update, back to default categories when the product sets were defined. There is a way to fix this.

Chris from approach me with a little issue they had when they update their products via the Datafeedr API. The Datafeedr API pulls in a collection of selected products into the WooCommerce store and creates and updates the products automatically. If the products are selected and a group from a list under the product sets (Datafeedr product setup page) they can be assigned default categories.

The problem was that they,, only manually define these categories for their products after it was added under Products in WooCommerce. So each time the products are updated via the Datafeedr API these categories will get replaced by the default categories. This will make sense for a lot of users to define the product categories beforehand, but through the years I have experienced first hand each business is a bit different. What works for you, might not work for someone else.

Datafeedr makes it easy to build and embed an affiliate store into your WordPress blog. No programming required. Promote products from thousands of merchants. Your store automatically updates.

My first approach was to unset the default taxonomy’s term ids been passed in the update process so that it does not revert back to the default categories.

Just a quick explanation about taxonomies and terms. Terms are Categories and many terms can belong to one taxonomy.

For example.:

Taxonomy: Product, for example the Product ‘category’ lets you group posts together by sorting them into various categories(terms).

Terms: Electronics, with child terms: Television, Camera.

There were some issues with some products not updating correctly after I applied my code. In the second attempt, after knowing the code of the plugin a bit better, I found a hook in the plugin that triggers the update method, the method that removes the existing custom defined product categories. These are the categories we are trying to keep and do not want it to be replaced by the default ones. On this hook, I created a function that stores all the current set term ids for a product under a custom metadata field of that specific post in the database. The post itself is not removed in the process, only the terms by default.  So when the update is performed I hooked into the update method and unset the default taxonomy terms that is about to be saved in the update process. Perform a database query for the temporarily stored term ids (I previously saved in the database) and add them to the array that is going to pass the newly updated content for the post (product). So, in short, the current taxonomy terms (categories) are added back as they were set manually before.

Click on the images to enlarge.

Posted in projects

01/2017 Work performed for this task.: Create new custom variables to be used on their sensei certificates since it only comes with a limited set of variables.: Sensei Certificate Customize Text. Needed to create a staging server to get a clone copy of the client setup so that my development did not affect the client’s live…
Read More

Dynamic Mobile Dentistry

08/2015 & 01/2017 Work performed for this task.: Coding of 3x digital templates that replicated the 3x official paper versions with 100% precision. Every single field, word, text line and box(s) was coded by hand. To accommodate the data, from the form that was filled out, every box and font size needed to be measured and adjusted…
Read More
Copy Linder Architects Mockup of Work Screenshits

Cope Linder Architects

Project Period: 03/2016 – 05/2016   Work performed for this task.: Continued Consultation, to discuss the work. Planning Process. Setup a staging server to perform the development of the new WordPress site. Export all data from PyroCMS and import it back into the new WordPress database as post types. Recreate all page layouts on newly…
Read More