- Issue created by @youssef.maaddi
I'm facing an issue while upgrading the Group module from version 1.5 in Drupal 9 to version 3.0 in Drupal 10. After resolving several errors during the upgrade process, I'm now stuck with the following problem.
Previously, I was using the getContentEntities() method in my code like this:
$group->getContentEntities(NULL, ['type' => 'account-group_node-ship_to']);
However, after upgrading to Group 3.0, I encountered the following error:
Error: Call to undefined method Drupal\group\Entity\Group::getContentEntities() in Drupal\accounts\Service\Customer\AccountProvider->getShipsToIdsById() (line 374 of modules/custom/accounts/src/Service/Customer/AccountProvider.php).
It appears that the getContentEntities() method no longer exists in the new release.
After reviewing the change records documentation → , I discovered that the Group module's getContentEntities() method has been replaced with getRelatedEntities() in Group module 3.0, which serves as an equivalent function :
$group->getRelatedEntities($plugin_id);
In my previous implementation, I utilized the getContentEntities() method with two parameters. The first parameter was set to NULL, and the second parameter was an array ['type' => 'account-group_node-ship_to']
By calling the getRelatedEntities() method on the group object and passing the $plugin_id, which in your case is 'group_node-ship_to', the new implementation will be :
$relatedEntities = $group->getRelatedEntities('group_node:ship_to');
knowing that the plugin_id stored in the table group_relashion_field_data is 'group_node:ship_to'
After dumping the result of $relatedEntities , The returned array is empty, despite the existence of the related entity.
Any suggestions or guidance on how to handle this situation would be greatly appreciated. Thank you in advance for your support!
Active
3.0
Code