Skip to content

Instantly share code, notes, and snippets.

@victor-shelepen
Created July 24, 2014 06:43
Show Gist options
  • Save victor-shelepen/6dbc209765aee8f77113 to your computer and use it in GitHub Desktop.
Save victor-shelepen/6dbc209765aee8f77113 to your computer and use it in GitHub Desktop.
$language_list = array ('ru', 'uk');
foreach($article_list as $article) {
//$output .= print_r($article, 1);
$node = entity_create('node', array('type' => 'article', 'title' => $article['en']['title'], 'language' => 'en'));
$output .= $article['en']['title'] . '|<br>';
$node->get('body')->setValue($article['en']['body']);
foreach ($language_list as $language) {
$translation = $node->getTranslation('ru');
$output .= $article[$language]['title'] . '|<br>';
if (empty($article[$language]['title'])) {
continue;
}
$translation->get('title')->setValue($article[$language]['title']);
$translation->get('body')->setValue($article[$language]['body']);
}
$node->save();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment