<![CDATA[ Article/Wordpress Import..keeps going and going and going... - My Forums]]> https://forums.modx.com/thread/?thread=103331 <![CDATA[Article/Wordpress Import..keeps going and going and going...]]> https://forums.modx.com/thread/103331/article-wordpress-import-keeps-going-and-going-and-going#dis-post-556027

Suggestions?]]>
jmanson Dec 21, 2017, 05:48 PM https://forums.modx.com/thread/103331/article-wordpress-import-keeps-going-and-going-and-going#dis-post-556027
<![CDATA[Re: Article/Wordpress Import..keeps going and going and going...]]> https://forums.modx.com/thread/103331/article-wordpress-import-keeps-going-and-going-and-going#dis-post-561779
$postType = (string)$this->getXPath($item,'wp:post_type');


This is emptly, and nothing happens.

I have moved the line that gets the namespace "wp" :

$wp = $item->children('wp',true);


before this line, at the first position of the method, and changed the read of post_type by :


$postType = (string)$wp->post_type;



So, the method looks like this :

    public function createArticle(SimpleXMLElement $item) {
	
		$wp = $item->children('wp',true); // 2018-09-27 . moved here
        //$postType = (string)$this->getXPath($item,'wp:post_type');
        $postType = (string)$wp->post_type;
        if ($postType != 'post') return false;
        $settings = $this->container->getContainerSettings();
        $creator = $this->matchCreator((string)$item->xpath('dc:creator'.'/text()'),1);
        /** @var SimpleXMLElement $wp */
		//$wp = $item->children('wp',true);	// 2018-09-27 . moved
        $pubDate =  strtotime((string)$item->pubDate);
        if (empty($pubDate)) {
            $pubDate = strtotime((string)$wp->post_date);
        }

        /** @var Article $article */
        $article = $this->modx->newObject('Article');
        $article->fromArray(array(
            'parent' => $this->container->get('id'),
            'pagetitle' => $this->parseContent((string)$item->title),
            'description' => $this->parseContent((string)$item->description),
            'alias' => $this->parseContent((string)$wp->post_name),
            'template' => $this->modx->getOption('articleTemplate',$settings,0),
            'published' => $this->parsePublished($item),
            'publishedon' => $pubDate,
            'publishedby' => $creator,
            'createdby' => $creator,
            'createdon' => strtotime((string)$wp->post_date),
            'content' => $this->parseContent((string)$item->children('content',true)->encoded),
            'introtext' => $this->parseContent((string)$item->children('excerpt',true)->encoded),
            'show_in_tree' => false,
            'class_key' => 'Article',
            'context_key' => $this->container->get('context_key'),
        ));
        $article->setArchiveUri();
        $article->setProperties($settings,'articles');

        if (!$this->debug) {
            $article->save();
        }

        $this->importTags($article,$item);
        $this->importComments($article,$item);
        return $article;
    }
]]>
jacuve Sep 28, 2018, 09:09 AM https://forums.modx.com/thread/103331/article-wordpress-import-keeps-going-and-going-and-going#dis-post-561779