Skip to content

Commit 935d381

Browse files
authored
Merge pull request #162 from magefan/604-wordpress-comments-import
import comments from wp
2 parents c264a39 + b810a3e commit 935d381

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Model/Import/Wordpress.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function execute()
4747
while ($data = mysqli_fetch_assoc($result)) {
4848
/* Prepare category data */
4949
foreach (['title', 'identifier'] as $key) {
50+
/*$data[$key] = utf8_encode($data[$key]);*/
5051
$data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8');
5152
}
5253

@@ -122,6 +123,7 @@ public function execute()
122123
while ($data = mysqli_fetch_assoc($result)) {
123124
/* Prepare tag data */
124125
foreach (['title', 'identifier'] as $key) {
126+
/*$data[$key] = utf8_encode($data[$key]);*/
125127
$data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8');
126128
}
127129

@@ -215,6 +217,7 @@ public function execute()
215217

216218
/* Prepare post data */
217219
foreach (['post_title', 'post_name', 'post_content'] as $key) {
220+
/*$data[$key] = utf8_encode($data[$key]);*/
218221
$data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8');
219222
}
220223

@@ -259,10 +262,8 @@ public function execute()
259262
$commentParents = [];
260263

261264
while ($comments = mysqli_fetch_assoc($resultComments)) {
262-
263265
$commentParentId = 0;
264266
if (!($comments['comment_parent'] == 0)) $commentParentId = $commentParents[$comments["comment_parent"]];
265-
266267
$commentData = [
267268
'parent_id' => $commentParentId,
268269
'post_id' => $post->getPostId(),
@@ -274,13 +275,17 @@ public function execute()
274275
'creation_time' => $comments['comment_date'],
275276
];
276277

278+
if (!$commentData['text']) {
279+
continue;
280+
}
281+
277282
$comment = $this->_commentFactory->create($commentData);
278283

279284
try {
280285
/* Initial saving */
281286
$comment->setData($commentData)->save();
282287
$commentParents[$comments["comment_ID"]] = $comment->getCommentId();
283-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
288+
} catch (\Exception $e) {
284289
unset($comment);
285290
}
286291
}

0 commit comments

Comments
 (0)