How to fiend entities when using domain access ?
Example 1 : Without changing user session.
$query = \Drupal::entityQuery('node');
$query->condition(DOMAIN_ACCESS_FIELD, 'domain_id'); // Set the domain id hear
$query->condition('type', 'article');
$query->condition('status', 1);
$nids = $query->execute();
print_r($nids);
If you can't get all domains data, do as the Example 2.
Example 2 : Using admin user session.
// Call the account switcher service
$accountSwitcher = \Drupal::service('account_switcher');
// Switch to the admin user
$accountSwitcher->switchTo(new \Drupal\Core\Session\UserSession(['uid' => 1]));
$query = \Drupal::entityQuery('node');
$query->condition(DOMAIN_ACCESS_FIELD, 'domain_id'); // Set the domain id hear
$query->condition('type', 'article');
$query->condition('status', 1);
$nids = $query->execute();
print_r($nids);
// Switch back to old session.
$accountSwitcher->switchBack();
Comments1
essay writing services
I am glad to read your post Thank you so much .keep sharing this Insightful Drupal. It's a happy for me to read your article. Keep spread out information so that everyone will be aware of this. I would like you to recommend high quality essay content from custom essay writing services it is helpful to students who are studying in higher studies.