From d3ed4fc4f814c1d61b2dc92ca28e41d14766518e Mon Sep 17 00:00:00 2001 From: Andriy Martynovskyj Date: Thu, 17 May 2018 18:24:15 +0300 Subject: [PATCH 1/2] import comments from wp --- Model/Import/Wordpress.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Model/Import/Wordpress.php b/Model/Import/Wordpress.php index c2ba3abe..cb0a3843 100644 --- a/Model/Import/Wordpress.php +++ b/Model/Import/Wordpress.php @@ -47,7 +47,8 @@ public function execute() while ($data = mysqli_fetch_assoc($result)) { /* Prepare category data */ foreach (['title', 'identifier'] as $key) { - $data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8'); + $data[$key] = utf8_encode($data[$key]); +// $data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8'); } $data['store_ids'] = [$this->getStoreId()]; @@ -122,7 +123,8 @@ public function execute() while ($data = mysqli_fetch_assoc($result)) { /* Prepare tag data */ foreach (['title', 'identifier'] as $key) { - $data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8'); + $data[$key] = utf8_encode($data[$key]); +// $data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8'); } if ($data['title']{0} == '?') { @@ -215,7 +217,8 @@ public function execute() /* Prepare post data */ foreach (['post_title', 'post_name', 'post_content'] as $key) { - $data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8'); + $data[$key] = utf8_encode($data[$key]); +// $data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8'); } $creationTime = strtotime($data['post_date_gmt']); @@ -259,10 +262,8 @@ public function execute() $commentParents = []; while ($comments = mysqli_fetch_assoc($resultComments)) { - $commentParentId = 0; if (!($comments['comment_parent'] == 0)) $commentParentId = $commentParents[$comments["comment_parent"]]; - $commentData = [ 'parent_id' => $commentParentId, 'post_id' => $post->getPostId(), @@ -274,13 +275,17 @@ public function execute() 'creation_time' => $comments['comment_date'], ]; + if (!$commentData['text']) { + continue; + } + $comment = $this->_commentFactory->create($commentData); try { /* Initial saving */ $comment->setData($commentData)->save(); $commentParents[$comments["comment_ID"]] = $comment->getCommentId(); - } catch (\Magento\Framework\Exception\LocalizedException $e) { + } catch (\Exception $e) { unset($comment); } } From b810a3e43de8274b94779736a4eb4151998980f4 Mon Sep 17 00:00:00 2001 From: Magefan Date: Fri, 25 May 2018 15:05:24 +0300 Subject: [PATCH 2/2] Update Wordpress.php --- Model/Import/Wordpress.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Model/Import/Wordpress.php b/Model/Import/Wordpress.php index cb0a3843..62f38f3e 100644 --- a/Model/Import/Wordpress.php +++ b/Model/Import/Wordpress.php @@ -47,8 +47,8 @@ public function execute() while ($data = mysqli_fetch_assoc($result)) { /* Prepare category data */ foreach (['title', 'identifier'] as $key) { - $data[$key] = utf8_encode($data[$key]); -// $data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8'); + /*$data[$key] = utf8_encode($data[$key]);*/ + $data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8'); } $data['store_ids'] = [$this->getStoreId()]; @@ -123,8 +123,8 @@ public function execute() while ($data = mysqli_fetch_assoc($result)) { /* Prepare tag data */ foreach (['title', 'identifier'] as $key) { - $data[$key] = utf8_encode($data[$key]); -// $data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8'); + /*$data[$key] = utf8_encode($data[$key]);*/ + $data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8'); } if ($data['title']{0} == '?') { @@ -217,8 +217,8 @@ public function execute() /* Prepare post data */ foreach (['post_title', 'post_name', 'post_content'] as $key) { - $data[$key] = utf8_encode($data[$key]); -// $data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8'); + /*$data[$key] = utf8_encode($data[$key]);*/ + $data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8'); } $creationTime = strtotime($data['post_date_gmt']);