I have been working on a considerably large project for a while which involves, amongst other things, importing quite a considerable amount of data from a wordpress site.
Alas, through the means I have been given (CSV reading loops/ Direct SQL manipulation / The processwire wordpress import module, btw THANK YOU) I have managed to get most of it working and the site is nearly done... except for one thing.
All of my comment's dates are set as the one in which they were created... on the new site.
Now I do happen to have a CSV that contains all of the data I need to work with, and have even set up a quick test on a sample page with only a single comment.
So, the problem here is that no matter how many times I save the field, the created time doesn't seem to change at all.
Just to verify.
$article = $pages->get("template=article,name=health-care-and-neighborhood-watch");
echo $article->title."__WPID: ".$article->post_id."<br>";
if (($handle = fopen("comments.csv", "r")) !== FALSE) {
$article->of(false);
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
//$data[1] is the article id;
//$data[7] is the approval date, we're using that as created.
if($data[1]==$article->post_id){
foreach($article->comments as $c){
if($c->cite==$data[2]&&$c->text=$data[8]){
echo "Previous date: ".date("Y-m-d",$c->created);
$c->created=strtotime($data[7]);
echo "<br>"."New and Improved date: ".date("Y-m-d",$c->created);
}
}
}
}
if($article->save()){
echo "<br> SAVED! :)";
}
fclose($handle);
}else{
echo "File not found";
}
I am targeting the right page. Output formatting is off. The page is supposedly even getting saved, but the created value for that comment does not seem to change in between different loops.
Is there something I am missing to make my import happen? Or is there another way in which I can get my comments imported differently?
I would very much appreciate this help.