# Configuration

> Configure the qoliber SEO Friendly Product URLs extension — define URL patterns, allowed attributes, and admin behaviour.

All settings live under **Stores → Configuration → Qoliber → SEO: Product Friendly URLs**.

## URL pattern

Define the template used to build product URL keys. Use attribute codes wrapped in curly braces.

```
{brand}-{name}-{sku}
{name}-{color}-{size}
{manufacturer}-{model}-{year}
```

The module slugifies the resolved string (lower-case, hyphens, no special characters) before writing.

## Eligible attributes

A multiselect that controls which product attributes are available in the pattern field. Limit this to attributes that are populated for every product in the catalogue — otherwise the resulting URL keys will contain empty segments.

Recommended candidates:

- `name`, `sku`, `manufacturer`, `brand`
- Single-value `select` attributes with global scope (`color`, `material`)
- Custom text attributes maintained by the merchandising team

Avoid:

- Multi-select attributes (lead to unpredictable URL length)
- Customer-specific attributes
- Attributes not maintained on every product

## Admin "Generate URL" button

- **Enable button** — show or hide the button in the product SEO section.
- **Force regenerate on each click** — when off, the button is a no-op for products with an existing URL key. When on, every click regenerates.

## CLI options

Bulk regeneration is exposed via the CLI:

```bash
bin/magento qoliber:seo:regenerate-urls \
  --entity-id-from=<int> \
  --entity-id-to=<int> \
  --store-id=<int>
```

| Option | Required | Notes |
|--------|----------|-------|
| `--entity-id-from` | yes | Inclusive lower bound on product entity ID. |
| `--entity-id-to` | yes | Inclusive upper bound on product entity ID. |
| `--store-id` | yes | Store view to regenerate URLs for. |

Wrap large runs in a `screen`/`tmux` session — the command runs synchronously and reports per-product progress.

## Per-store configuration

URL patterns can differ per store view. A French store can use `{name}-{couleur}-{taille}` while the English store uses `{name}-{color}-{size}`.

## Collision handling

The module always checks the `url_rewrite` table for an existing entry on the resolved request path before writing. On collision the module:

- For batch CLI runs: skips the conflicting product and reports the conflict in the output.
- For admin button: prompts the merchant with the conflict.

Cross-entity collisions (against CMS pages or categories) are always rejected — never auto-overwritten.
