Skip to main content

Posts

Drupal 8 : How to create the node programaticaly in drupal 8?

use Drupal\Core\Language\LanguageInterface; $node = Node::create(array(     'uid' => '1',     'title' => 'Article Test',     'type' => 'article',     'status' => NODE_PUBLISHED,     'promote' => 1,     'sticky' => 0,     'body' => array(         'value' => 'Hello World!',     ),     'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,   ))->save();   $node->addTranslation($this->translateToLangcode, array(     'title' => $this->translatedLabel,   )); $node->save();