import:listing.data_before_save
Filters listing data during CSV import before saving to database. Custom fields are in $data['fields'] as arrays (converted from asterisk format). Standard fields are at root level. Must return data with same structure.
You need to have a working knowledge of Hooks before you get started.
Fires during CSV import after data transformation but before saving listing
Parameters
| Name | Type | Description |
|---|---|---|
$data |
array |
Data array with standard fields at root and custom fields in 'fields' key as arrays |
$listing |
\JReviews\App\Models\Listing|null |
The listing being updated (null for new listings) |
Boilerplate Code
Use the boilerplate code to start using the filter, and add your own logic to modify the first argument and return it.
fwd_add_filter('import:listing.data_before_save', function($data, $listing)
{
// Your code here
return $data;
}, 20, 2);
The , 20, N after your callback are the hook priority and the number of arguments your callback accepts. By default, a hook passes your callback only its first argument; for a filter, that is the value being filtered, so a simple function($value) { ... } needs nothing extra. If your callback declares more parameters, such as function($value, $listing) { ... }, you must add N (the parameter count, 2 here). Because N is the fourth argument to fwd_add_filter() or fwd_add_action(), you must also pass the priority (20 is the default). Leaving these off when your callback expects extra parameters causes a Too few arguments to function ... fatal error.
Source Files
app/Actions/HandleListingImportJobAction.php