Stephan Miller

12 Jun, 2007

Importing ShareASale Datafeeds into Drupal Part 2

Posted by: User ImageStephan Miller In: Affiliate Programs| Drupal

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

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.

Rate this:
2.5

1 Response to "Importing ShareASale Datafeeds into Drupal Part 2"

1 | winnie

August 10th, 2007 at 8:31 pm

Avatar

this looks really good. I hope to hear more details on how you manage to import it. Perhaps you can make a video about it? :P

Comment Form

WTFMO



Flickr PhotoStream

  • 101_0226
  • 101_0224
  • 101_0225
  • 101_0222

About

This is my blog about building sites, traffic and using those to make money from ecommerce sites, affiliate programs and blogging.

Subscribe By Email



The One and Only Blogging Magazine

Popular Posts