- Issue created by @saahbaa
- First commit to issue fork.
I did some changes to debug the function:
private function setValue($paragraph, $value) {
$target = $this->target->getName();// Check if paragraph is null
if ($paragraph === null) {
\Drupal::logger('feed_para_mapper')->error("Paragraph is null.");
return; // or handle the error
}// Check if paragraph is an instance of EntityInterface
if (!$paragraph instanceof \Drupal\Core\Entity\EntityInterface) {
\Drupal::logger('feed_para_mapper')->error("Invalid paragraph entity.");
return; // or handle the error
}// Check if target property exists
if (property_exists($paragraph, $target)) {
$paragraph->{$target} = NULL;
// Log the current value
\Drupal::logger('feed_para_mapper')->info("Current value: @value", ['@value' => print_r($paragraph->{$target}, true)]);
} else {
// Handle case where the target property does not exist
\Drupal::logger('feed_para_mapper')->warning("Target property does not exist: @target", ['@target' => $target]);
}// Set the target value
$this->instance->setTarget($this->feed, $paragraph, $target, $value);
}so now it will import the ONLY the first referenced paragraph ...
but still the issue exist if you want to map more than 1 referenced paragraphnow I am trying to create the paragraph:
private function setValue($paragraph, $value) {
$target = $this->target->getName();// Check if the paragraph is null
if ($paragraph === null) {
// Prepare host info
$host_info = [];
$entity = $this->entity; // Use the current entity as the parent
$host_info['bundle'] = 'paragraph'; // Use the method to get the bundle
$host_info['field'] = $target; // Use the target as the field
$host_info['entity'] = $entity;// Call createParagraph to create a new paragraph
$paragraph = $this->createParagraph($host_info['field'], $host_info['bundle'], $host_info['entity']);
\Drupal::logger('feed_para_mapper')->info('Paragraph type: @type', ['@type' => $paragraph->getType()]);
} else {
// Reset the values of the target if paragraph already exists
$paragraph->{$target} = NULL;
\Drupal::logger('feed_para_mapper')->info('Paragraph type: @type', ['@type' => $paragraph->getType()]);
}// Set the target and prepare values
$this->instance->setTarget($this->feed, $paragraph, $target, $value);
}Is there any update on this please?
I really need to import more than 1 paragraph on a same parent field. But it always imports only 1It always imports only 1 paragraph into the same parent field
Scenario is:
Content type : Page
Field: Content (has multiple paragraph references including text, related content, documents)
it only imports the first reference. if if I first map text target it only imports that and ignore the next one which is related content
If I map related content first it will import that and ignores the text
if I call explode() in the beginning of the import() function it will only import the last target