Importing ShareASale Datafeeds into Drupal Part 2

Importing ShareASale Datafeeds into Drupal Part 2

Okay, there is an issue using Node Import to import ShareASale datafeeds.

Either the datafeed itself or the import process makes characters like “&” come up as character codes. I have had the same issue before with xml files, but now is not the time to investigate, just to fix the issue.

My solution, though a little hacky, was to create a page in Drupal with the import format set to “php code” and then paste code to clean these characters.

The three tables to focus on are:

  • term_data
  • node
  • node_revisions

Here is the code:

<?php $deletes = array ( “&” => “&”, “’” => “'”, “>” => “>”); foreach($deletes as $remove=>$replace){ $cleantagquery = “UPDATE {term_data} SET name=REPLACE(name,’$remove’,’$replace’)”; db_query($cleantagquery); $cleantitlequery = “UPDATE {node} SET title=REPLACE(title,’$remove’,’$replace’) WHERE type = ‘store’”; db_query($cleantitlequery); $cleanrevtitlequery = “UPDATE {node_revisions} SET title=REPLACE(title,’$remove’,’$replace’)”; db_query($cleanrevtitlequery); $cleanrevbodyquery = “UPDATE {node_revisions} SET body=REPLACE(body,’$remove’,’$replace’)”; db_query($cleanrevbodyquery); } if(mysql_error()){ echo mysql_error(); }else{ echo “Done!”; }

?>

Of course, Wordpress just changed the character entities back to the character, but you get the idea.


Stephan Miller

Written by

Kansas City Software Engineer and Author

Twitter | Github | LinkedIn

Updated