Create position column

From PrestaShop/PrestaShop · View interactive version

Create position column is an AI agent skill from the GitHub repository PrestaShop/PrestaShop. Documents how to add drag-and-drop row reordering to a PrestaShop grid. Requires a PositionColumn in the definition, a ReorderPositionsButtonType filter, a dedicated update-position route, and position handling in the repository.

How to use this skill

Skill file

create-position-column

Canonical reference: CODE0.

Instructions

  1. Add PositionColumn as the second column (after BulkActionColumn) in the Grid Definition.
  2. Configure the position update route: ->setOption('update_method', 'POST')->setOption('update_route', 'admin_{domain}s_update_position').
  3. Add a ReorderPositionsButtonType filter associated with the position column (see Rules below) — mandatory, not optional.
  4. Create the admin_{domain}s_update_position POST route in the routing YAML (see create-admin-routing skill).
  5. In the controller, handle the AJAX position update: receive positions[] array, dispatch UpdatePosition{Domain}Command (or use QueryBuilder directly).
  6. In the repository, update the position column for the moved entities.

Rules

Column ordering conventions (PositionColumn as second column) are in Grid/CONTEXT.md. Skill-specific reminders:

```php

use PrestaShopBundle\Form\Admin\Type\ReorderPositionsButtonType;

->add((new Filter('position', ReorderPositionsButtonType::class))

->setAssociatedColumn('position')

);

```

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.