# Data Patch Creator

> Generate Magento 2 PHP data patches directly from the Admin Panel — no manual coding required

The Data Patch Creator streamlines one of the most error-prone parts of Magento 2 development: creating PHP data patch files. Instead of manually writing patch classes, this module lets you generate them directly from the Admin Panel with a few clicks.

This is especially valuable in large teams where content changes (CMS blocks, product attributes, store configs) need to be version-controlled and deployed consistently across environments. Without data patches, these changes live only in the database and get lost during deployments — the Data Patch Creator ensures they're captured as code.

**GitHub:** [qoliber/m2-datapatchcreator](https://github.com/qoliber/m2-datapatchcreator)

## Installation

```bash
composer require qoliber/module-datapatchcreator
bin/magento setup:upgrade
```

## Features

- **One-click patch generation** — Select any supported entity in the Admin Panel and export it as a PHP data patch file
- **Bulk export** — Generate patches for multiple entities at once, downloaded as a ZIP file ready to drop into your module
- **Image synchronization** — Syncs images across Magento instances using `ImageSyncInterface`, ensuring media is consistent between environments
- **Custom sync methods** — Implement your own image sync strategy via dependency injection (S3, CDN, shared storage)
- **Broad compatibility** — Works with PHP 7.3+ and Magento 2.3.x through 2.4.x

## Supported Entity Types

| Entity | What gets patched |
|--------|------------------|
| **Product attributes** | Attribute definition, options, labels, sort order |
| **CMS pages** | Title, content, layout, stores, URL key |
| **CMS blocks** | Identifier, title, content, stores |
| **Store configurations** | Config path, value, scope |

<Admonition type="warning" title="PageBuilder Compatibility">
The main module is not compatible with PageBuilder for Magento 2.4.3+. Install the companion package for PageBuilder support:

```bash
composer require qoliber/m2-datapatchcreator-pagebuilder
```
</Admonition>

## How It Works

1. Navigate to the entity you want to patch in the Magento Admin
2. Click the "Create Data Patch" button (available on supported entity edit pages)
3. The module generates a properly structured PHP data patch class
4. Download the file and place it in your module's `Setup/Patch/Data/` directory
5. Run `bin/magento setup:upgrade` — the patch executes and your content is now version-controlled
