You are here:  » Using my own feed as first/leading productfeed

Active Forum Topics


Using my own feed as first/leading productfeed

Submitted by webblish on Mon, 2018-03-12 10:37 in

I want to publish an extended database with products on my WordPress website. It will have a lot of custom fields. Most of the productdata is collected by hand, since the productfeeds of the webshops aren't very complete. I want to put all the data in a Google spreadsheet, so my co-worker and I can change the data anytime and anywhere.

1) I would like to import that spreadsheet as the first (leading) feed in PT. But: my own database doesn't have any prices. Is that a problem?

2) After that, we will import some affiliate feeds. I'm al little worried that our own data will be overwritten. Is our data safe? (I'm pretty sure this is a pretty stupid question..)

Submitted by support on Mon, 2018-03-12 12:38

Hi,

What I would suggest here is that rather than treat your spreadsheet managed data as a feed, is to use it as a reference feed containing values by product name to override (or provide in the absence of) the fields from your affiliate feeds.

Make sure that your column headings in the spreadsheet match exactly the field names on the `pt_products` table, with name as the first column, followed by the fields you want to override e.g. category, brand and your custom fields. When you export the spreadsheet as a .csv file, use "quoted text", and save the file in your feeds/ folder as reference.csv. The output you're looking for, using two products and to override category, brand and custom_field_1 would be;

"name","category","brand","custom_field_1"
"Product 1","Category 1","Brand 1","Custom Field 1 Value 1"
"Product 2","Category 2","Brand 2","Custom Field 1 Value 2"

With the reference feed in place, edit includes/admin.php and add the following new function at the very top of the script, immediately after the opening PHP tag:

  function admin_myReferenceRecordHandler($record)
  {
    global $admin_importReference;
    $admin_importReference[$record["name"]] = $record;
  }

Then look for the following code at (now) line 467:

    /* create normalised version of product name for use in URLs */

...and REPLACE with:

    global $admin_importReference;
    if (isset($admin_importReference[$importRecord["name"]]))
    {
      $importRecord = array_merge($importRecord,$admin_importReference[$importRecord["name"]]);
    }
    /* create normalised version of product name for use in URLs */

And finally the following code at (now) line 571:

    global $admin_importFilters;

...and REPLACE with:

    global $admin_importFilters;
    global $admin_importReference;
    global $config_feedDirectory;
    if (!isset($admin_importReference))
    {
      MagicParser_parse($config_feedDirectory."reference.csv","admin_myReferenceRecordHandler","csv|44|1|34");
    }

With that in place, at import time values from your reference will override or be used in the absence of any values from your affiliate feeds.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com