You are here:  » Change in datafeed


Change in datafeed

Submitted by JasonG on Wed, 2013-05-08 08:38 in

Hi David

I am sure this is probably something you have come accross before where a merchant decides to change it's data feed

The issue I have is as follows:

The merchant used to split the categories, which I map under a heading called "merchant_category" and then have "Dog Shop > Dog Beds & Baskets > Dog Blankets > Fleece & Soft Blankets"

We use the second part "dog beds and baskets" and map that to our category

The merchant has now put the structure under "specifications" and uses "Dog > Dog Toys & Sports Accessories > Squeaker Toys > Latex & Vinyl Squeakers"

So the column and name has changed and also the category name

We are planning to automate feed imports and if a merchant chages things like above, what would be the best way to handle this, any scripts that would detect the change and do something like if X is then do Y

Might not be possible as we would never know what the change is without a manual check - Help!

Thanks
Stuart

Submitted by support on Wed, 2013-05-08 09:07

Hi Stuart,

Something a number of users have implemented is to have the import process send you an email alert if any feed imports zero products, which is easy to do. In includes/admin.php look for the following code at line 519:

  $productCount = $rows[0]["productCount"];

...and REPLACE with:

  $productCount = $rows[0]["productCount"];
  if (!$productCount)
  {
    mail("you@example.com","Failed Import Alert","Feed: ".$filename);
  }

This would certainly alert you if a merchant changed their feed format for example - as it would no longer match the existing registration no products would be imported - and should be easily resolve by re-registering to the new format of course.

I guess one way to detect a more subtle change would be to check that at least one product record from the feed that has just been imported has every registered field populated. That way, if, as in your example, a merchant simply changes the name of the category field in their feed then this could be picked up as follows (slightly different place in the code for this one). In the same file, look for the following code at line 525:

  return "";

...and REPLACE with:

  global $config_fieldSet;
  $wheres = array();
  foreach($config_fieldSet as $field)
  {
    $wheres[] = "`".$field."` <> ''";
  }
  $where = implode("AND",$wheres);
  $sql = "SELECT id FROM `".$config_databaseTablePrefix."products` WHERE ".$where." AND filename='".database_safe($filename)."' LIMIT 1";
  if (!database_querySelect($sql,$rows))
  {
    mail("you@example.com","Possible Feed Format Change Alert!","Feed: ".$filename);
  }
  return "";

Cheers,
David.
--
PriceTapestry.com