# Export Selected Products

I have an existing Laravel project using Filament.

I want to complete the **product export** feature in the admin panel.

## Current Behavior

The existing export is **category-based only**:

- The Products Overview/List page has an `Export Products` header action.
- It requires picking a category and a format (CSV / PDF).
- `ProductExportService` exports all products belonging to that category.

This is not flexible enough.

## Goal

Allow the admin to **select the exact products they want to export** directly from the

```text
Products → Overview / List
```

page, and export **exactly the filtered and sorted set** visible in the overview.

The category is **no longer required** (or used) for export.

## UI Requirements

### 1. Per-row selection checkboxes

Every product row in the Products Overview table must have a selection checkbox.

### 2. Select all (filtered/sorted products)

The table header must provide a **select-all** control that selects **all products matching the current filter and sort**, not just the current page.

### 3. Multi-page persistence

Selections must be **preserved when the admin navigates between pages** of the overview. Products selected on an earlier page must not be missed.

### 4. Selection survives filter/sort/search changes

Changing the filters, sort order, or the search term must **not clear** the existing selection. The admin builds a set of products step by step and it must be kept across those interactions.

### 5. Export action

Keep a single header action that opens a modal to choose the format (CSV / PDF). The action must:

- Show the number of currently selected products.
- Warn/block when nothing is selected.
- Export only the selected products, preserving the overview's current filtered + sorted order.

## Implementation Notes

- Filament tables provide selection checkboxes (`selectable()`) and select-all across filtered records natively. Use the framework capabilities rather than re-inventing the selection UI.
- By default Filament clears the selection when filters/search change; explicitly opt out so the selection is kept (`deselectAllRecordsWhenFiltered(false)`).
- Selected records should be read via the table's selection state, which returns records ordered by the table's current sort.
- `ProductExportService` must be decoupled from categories. It should accept a collection of products (already in export order) plus a title used for the document heading and download filename.
- The exported price must be the same meaningful value in both CSV and PDF (the product `discount_price`).

## Acceptance Criteria

- [ ] Each product row in the Products Overview has a selectable checkbox.
- [ ] The header select-all control selects all products matching the current filters/sort across all pages.
- [ ] Navigate between pages and the selection is retained.
- [ ] Changing filters/sort/search keeps the previously selected products.
- [ ] The export modal shows the selected count.
- [ ] Exporting with zero selected products shows a clear error and does not produce an empty file.
- [ ] CSV export contains exactly the selected products, in the overview's current sort order, with the real price value.
- [ ] PDF export contains exactly the selected products, in the overview's current sort order.
- [ ] The category-based export is removed; no category is required to export.
- [ ] Existing Products Overview functionality (search, filters, sorting, edit, bulk actions) still works.