Skip to content
Back to skills

Prestashop Form Data Providers

ASecurity

Skill for modifying core PrestaShop form data using modern Data Provider hooks in PS 8/9.

  • 4 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 28, 2026
developmentgophpdebuggingdatabaseperformance

Security analysis

A100/100

Scanned September 28, 2026

npx -y skills add ecomyseo/prestashop_skills --skill prestashop-form-data-providers --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Prestashop Form Data Providers?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Prestashop Form Data Providers
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecomyseo-prestashop-form-data-providers/badge)](https://www.skillsdirectory.com/skills/ecomyseo-prestashop-form-data-providers)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
name: prestashop-form-data-providers
description: Skill for modifying core PrestaShop form data using modern Data Provider hooks in PS 8/9.
---

# PrestaShop Form Data Providers Skill

This skill explains how to use the `action*FormDataProviderData` and `action*FormDataProviderDefaultData` hooks to modify the data before it is displayed in modern Symfony forms (like the Product V2 form).

## 1. Technical Guide

### Modifying Default Data (New objects)
Use `hookActionProductFormDataProviderDefaultData` to set default values for new products.

```php
public function hookActionProductFormDataProviderDefaultData(array $params): void
{
    // $params['data'] is an array mirroring the form structure
    $params['data']['details']['references']['mpn'] = 'DEFAULT_MPN_123';
}
```

### Modifying Existing Data
Use `hookActionProductFormDataProviderData` to modify data being loaded for an existing object.

```php
public function hookActionProductFormDataProviderData(array $params): void
{
    $productId = (int) $params['id'];
    $currentMpn = $params['data']['details']['references']['mpn'];

    if ($this->shouldPrefixMpn()) {
        $params['data']['details']['references']['mpn'] = 'PREFIX_' . $currentMpn;
    }
}
```

### Supported Entities
These hooks are generally available for any modern form using a `FormDataProvider`. Most commonly:
- `Product` (V2)
- `Combination`
- `Category` (in newer versions)

## 2. Professional Development Guide

### Advantages over Overrides
- **Non-destructive**: You are only modifying the array of data used by the form, not the database structure or core classes.
- **Composable**: Multiple modules can hook into the same data and add their own modifications without conflicts.

### Best Practices
- **Path Awareness**: You must know the exact array path of the field you want to modify. Refer to the form type definitions or dump the `$params['data']` during development.
- **Conditional Logic**: Always check if the store context or object ID is correct for your modification.

## 3. User Guide

### Debugging
If values are not appearing as expected:
1. Ensure the module is hooked to the correct event.
2. Check the PrestaShop version (hook availability depends on the Symfony migration state of that specific page).
3. Clear Symfony cache (`var/cache/`).

## Rules & Best Practices
- **Performance**: Avoid heavy database queries inside these hooks as they are called during every form load.
- **Safety**: Check for the existence of array keys before accessing/modifying them to avoid "Undefined Index" errors.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.