Import label

This is the filament importer file which is used for import prices Here when I try to click "Download example CSV file", it is giving the CSV file with the column names like name, sku, price etc. It is not getting the label names which has mentioned in the getColumns() function. So what adjustments or configurations might be needed to fix this?
<?php

namespace App\Filament\Imports\Dealer;

use App\Models\DealerPrice;
use App\Models\Product;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;

class PriceImporter extends Importer
{
public static function getColumns(): array
{
return [
ImportColumn::make('name')
->label(__('filament-forms::components.name'))
->examples(['Sample Product 1', 'Sample Product 2', 'Sample Product 3'])
->relationship('product', 'name'),

ImportColumn::make('sku')
->label('SKU')
->examples(['ABC123', 'XYZ456', 'LMN789'])
->relationship('product', 'sku'),

ImportColumn::make('db_number')
->label(__('filament-forms::components.db_no'))
->examples(['DB001', 'DB002', 'DB003'])
->relationship('product', 'db_number'),

ImportColumn::make('ean_number')
->label(__('filament-forms::components.ean_no'))
->examples(['1234567890123', '9876543210987', '5678901234567'])
->relationship('product', 'ean_number'),

ImportColumn::make('price')
->label(__('filament-forms::components.dealer_price'))
->examples([249.99, 459.50, 120.00])
->requiredMapping()
->rules(['required', 'numeric', 'min:0'])
->numeric(true, 2)
];
}

... Removed the rest of the code ...
}
<?php

namespace App\Filament\Imports\Dealer;

use App\Models\DealerPrice;
use App\Models\Product;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;

class PriceImporter extends Importer
{
public static function getColumns(): array
{
return [
ImportColumn::make('name')
->label(__('filament-forms::components.name'))
->examples(['Sample Product 1', 'Sample Product 2', 'Sample Product 3'])
->relationship('product', 'name'),

ImportColumn::make('sku')
->label('SKU')
->examples(['ABC123', 'XYZ456', 'LMN789'])
->relationship('product', 'sku'),

ImportColumn::make('db_number')
->label(__('filament-forms::components.db_no'))
->examples(['DB001', 'DB002', 'DB003'])
->relationship('product', 'db_number'),

ImportColumn::make('ean_number')
->label(__('filament-forms::components.ean_no'))
->examples(['1234567890123', '9876543210987', '5678901234567'])
->relationship('product', 'ean_number'),

ImportColumn::make('price')
->label(__('filament-forms::components.dealer_price'))
->examples([249.99, 459.50, 120.00])
->requiredMapping()
->rules(['required', 'numeric', 'min:0'])
->numeric(true, 2)
];
}

... Removed the rest of the code ...
}
1 Reply
charlie
charlie4w ago
ImportColumn::make('sku')
->exampleHeader('SKU')
ImportColumn::make('sku')
->exampleHeader('SKU')
https://filamentphp.com/docs/3.x/actions/prebuilt-actions/import#providing-example-csv-data

Did you find this page helpful?