Import CSV, Merge Columns

Hi Thanks for looking / reading. i hope you can help i have a "Code" Column in my DB and the CSV files i get come from multiple sources and could be named differently in seperate columns e.g EAN, Code, PipCode . . . is there away i can select multiple fields "EAN, Code, PipCode" , im still searching the inter-web for some help .. thought i'd post in here whilst i keep looking again thanks for any help!
6 Replies
Mocus
MocusOP3w ago
Thanks but finding the column is not a problem, I'm looking for way to merge columns, it allows me to select a simple column but I want to choose multiple
toeknee
toeknee3w ago
So use the above to find / allocation. Then on that column format the state getting all the columns and merging them together? as per: https://filamentphp.com/docs/3.x/actions/prebuilt-actions/import#customizing-how-a-column-is-filled-into-a-record
use App\Models\Product;

ImportColumn::make('sku')
->fillRecordUsing(function (Product $record, string $state): void {
$record->code = $record->ean . ' - ' . $record->sku;
})
use App\Models\Product;

ImportColumn::make('sku')
->fillRecordUsing(function (Product $record, string $state): void {
$record->code = $record->ean . ' - ' . $record->sku;
})
I believe
Mocus
MocusOP3w ago
thanks for the response, ideally id like to make the column choice fields checkboxes instead of drop downs or checkboxes in the drop down maybe
toeknee
toeknee3w ago
Then you need to build your own 🙂
Mocus
MocusOP3w ago
yep it's looking like that indeed, well thanks for the help !

Did you find this page helpful?