Pass the record to the importer class

I’m currently using the importer action in a relation manager. What’s the best way to pass the ownerRecord to the importer and use it in resolveRecord to set the relationship ID accordingly?

ImportAction::make('importSearchQueries')
    ->iconSize(IconSize::Small)
    ->label(__('Import'))
    ->importer(SearchQueriesImporter::class),


->firstOrCreate([
    'query' => $this->data['query'],
    // Retrieve the ownerRecord?
    'relation_id' => 1,
]);
Solution
Here is how you can pass data to the importer:

ImportAction::make('importSearchQueries')
  ->importer(SearchQueriesImporter::class)
  ->options(['is_cool' => true])


You can then use the following in your importer file.

$this->options['is_cool']
Was this page helpful?