- Issue created by @yorchperaza
I am encountering an error when trying to programmatically create paragraphs and apply layout settings using the layout_paragraphs
module. The error occurs when I attempt to save the main entity that contains the paragraphs.
In SqlContentEntityStorage.php line 811:
paragraph.ERROR: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 of /var/www/app/core/lib/Drupal/Core/Entity/EntityTypeManager.php).
foreach ($json_data as $key => $value) { $paragraph = Paragraph::create([ 'type' => 'main_products', 'field_id' => $link['id'], 'field_text' => $link['text'], ]); // Set the layout $layoutSettings = [ 'layout_paragraphs' => [ 'layout' => 'layout_fourcol_section', 'config' => ['label' => ''], 'parent_uuid' => null, 'region' => null, ], 'mega_menu_behavior' => [] ]; $paragraph->setBehaviorSettings('layout_paragraphs', $layoutSettings); $current[] = $paragraph; } $mainEntity = CustomEntityLayoutBuilder::create([ 'type' => 'custom_entity_layout_builder', 'langcode' => $locale, 'field_menu_items' => $paragraphs, ]); $mainEntity->save();
The paragraphs should be created with the specified layout settings and saved without any errors.
An error is thrown indicating a problem with the entity type definition when trying to save the main entity.
What is the correct way to programmatically generate content for paragraphs using layout_paragraphs
? Any guidance or suggestions to resolve this error would be greatly appreciated.
Active
2.0
Code