Hi,
I'm creating a script to migrate redirects from an old site to the new one.
When a redirect is imported I want to check if that redirect already exists, if so update it instead of creating a new one.
But when I'm executing an entity query searching for the 'redirect_source' field I get an error that that field doesn't exist!
When I Devel a redirect the field clearly exists.
This is the query:
$rid = \Drupal::entityQuery('redirect')
->condition('redirect_source', $source)
->execute();
Does someone maybe know a solution to this?
Thanks,
- Perry
Comments
Comment #2
mr.baileysYou can use
\Drupal\redirect\RedirectRepository::findBySourcePath($source_path)to get redirect entities for a given source path.If you do want/need to use EntityQuery, the redirect_source field has multiple columns (path & query), so you'll need to specify the column name: