# mage-os/module-page-builder-template-import-export

> PageBuilder template import/export module

`composer require mage-os/module-page-builder-template-import-export`

Canonical URL: https://packagento.com/mage-os/module-page-builder-template-import-export

## At a glance

- **Vendor**: mage-os (https://packagento.com/mage-os.md)
- **Latest version**: 1.8.1 — released 2026-05-18
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/mage-os/module-page-builder-template-import-export and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require mage-os/module-page-builder-template-import-export:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

PageBuilder template import/export module

## README

Enrich PageBuilder adding templates import/export management.

---


### Overview

The **PageBuilder Templates Import/Export** module allows you to import and export pagebuilder templates through different magento instances.
You can use it exporting zip templates file locally and move to remote instances or pulling directly from a configured dropbox storage.

![remote_template_import](./doc/importremotetemplate_screenshot.png)
![remote_template_import_confirmation](./doc/importremotetemplate2_screenshot.png)
![remote_template_imported](./doc/importremotetemplate3_screenshot.png)
![apply_template](./doc/applytemplate_screenshot.png)
![template_applied](./doc/applytemplate2_screenshot.png)


### 🚀 Features

#### Export Template

Once the module is enabled you can export templates through adminhtml ui going to "Content > Elements > Templates" section clicking on the "Actions" column or through cli.
For cli export execute the following command:
```
php bin/magento mage-os:pagebuilder_template:export
```
As result of export you will obtain a .zip file containing the template.


#### Import Template

You can import templates from adminhtml ui always from the "Content > Elements > Templates" section.
At the top of the page you'll se a CTA "Import Template", clicking on it a modal opens with an "Upload button" find the zip file from the search window and select it.
Cli command is also supported for import:
```
php bin/magento mage-os:pagebuilder_template:import
```


#### Remote Template Import

Once you've configured one or more dropbox apps with success you'll be able to see the remote templates stored there inside the "Import Template" modal.
You will be able to filter them and import on you Magento instance clicking on "Import" link on "Action" column. 
Remote dropbox repositories are synced with configured in every dropbox app webhooks.
An alignment is done once per day at 0:00 but you can also make a full alignment executing the following cli command:
```
php bin/magento mage-os:pagebuilder_template:update-remote-list
```

### 🔧 Installation

1. Install it into your Mage-OS/Magento 2 project with composer:
    ```
    composer require mage-os/module-page-builder-template-import-export
    ```

2. Enable module
    ```
    bin/magento setup:upgrade
    ```

3. Add consumer to queue consumer list (suggested)

   Update your env.php file adding "pbTemplateImport" to consumers. 
   ```
    <?php
    return [
    ...
        'queue' => [
            'consumers_wait_for_messages' => 1
        ],
        'cron_consumers_runner' => [
            'cron_run' => true,
            ...
            'consumers' => [
                ...
                'pbTemplateImport'
                ...
            ]
        ]
    ...
    ];
    ```


### ⚙️ Configuration

The module provides configuration options under **Stores > Configuration > General > Content Management > Pagebuilder template import/export**


##### General Configuration

- **Enable**: Enables or disables the module. This setting is configurable on global scope.
- **Sync remote templates by cron**:  Let you decide to synchronize remote templates by cron (suggested for large sets of templates stored on remote. See point 3 of installation chapter) or directly after configuration save.
- **Dropbox repositories**: Allows you to specify the Dropbox apps from which to receive templates.


##### Dropbox repositories Configuration

To synchronize remote templates stored on a dropbox repository owned by a vendor you need to add a dropbox app.
Follow these instructions:
- Specify a name
- Specify the app_key
- Specify the app_secret (see https://www.dropbox.com/developers/apps or get them from the dropbox app owner)
- Specify the refresh token 

To synchronize remote templates stored on one of your own dropbox accounts add a dropbox app following these steps:
- Specify a name
- Specify the app_key
- Specify the app_secret (see https://www.dropbox.com/developers/apps and copy them)
- Click on "Generate and authorize refresh token" and follow the instructions to generate the one-time valid "access code"
- Paste "access code" inside the input below the "Refresh Token Generator" column and click the button
- Save the configuration clicking on the main configuration "Save" button
- If no errors where encountered during the saving process you'll be able to see a refresh token generated on the fifth column of the row you configured previously.

Congratulations! This credentials will be used for each dropbox api call to the related app storage.
This configuration is managed as multi-row so you can add multiple dropbox apps related to different repositories simultaneously.


##### Dropbox app Creation

In order to connect Magento with dropbox you need to create a dropbox app related to it: https://www.dropbox.com/developers/reference/getting-started
If you're configuring your own dropbox application for your Dropbox Account you must follow these steps:
1) Select "Scoped Access" on "Choose an API" section
2) Select "Full Dropbox" on "Choose the type of access you need" section
3) Add an app name ex: "My Mage-OS Template Storage"

![app_connection](./doc/configuration_screenshot.png)
![app_connected](./doc/configuration2_screenshot.png)
 

##### Dropbox app Configuration

The most important thing is setting the right permissions (following permissions are required):
- files.metadata.read
- files.content.read

If you are the owner on Dropbox space and you can manage the app directly you can also configure webhooks for realtime notification and sync.
To do so, add your site webhook endpoint inside "Webhook URIs" section as follows:
https://www.mysite.com/pagebuildertemplateie/template_remote/sync

If correct, your Magento instance will be updated realtime for any update on your Dropbox.

If you're not the owner of the Dropbox you must ask for webhook update to the owner.


### 🤝 Changelog

_(README truncated for .md surface. Full README on https://packagento.com/mage-os/module-page-builder-template-import-export.)_

## Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

### 1.8.1 - 2026-05-17
#### Fixed
- Declare `: int` return type on CLI commands for compatibility with Magento 2.4.9 and Mage-OS 3.

### 1.8.0 - 2026-04-21
#### Fixed
- PHP 8.4 and PHP 8.5 compatibility.
- Guard `trim()` against `file_get_contents()` returning `false` in `substituteAdminhtmlStaticUrl`.
- Guard `scandir()` and `file_get_contents()` false returns in `importTemplateChildren`.
- Null-safe access to `parse_url()` result keys in `TemplateManagement::doSecurityScanForTemplate` and `CmsConverter::substituteSiteUrls`.
- Null-safe `explode()` offset access in `CmsConverter::convert` when parsing pagebuilder media tokens.
- `ModuleConfig::getDropboxCredentials()` no longer passes non-string values to `unserialize()` and always returns an array.
- `ModuleConfig::getDropboxAccountCredentialsByAppKey()` no longer iterates non-array credentials.
- `ApiKeySerialized::beforeSave()` and `afterSave()` no longer iterate/unserialize non-array/non-string values.
- Removed invalid `return` statements from console command constructors (`ImportTemplate`, `UpdateRemoteTemplateList`).
- Replaced erroneous `PHPUnit\Util\Exception` usage with `LocalizedException` in the remote import controller.

#### Updated
- Widened `composer.json` PHP constraint to support PHP 8.1 through 8.5.

### 1.7.0
### Updated
- Add security check on external files imported through template.
- Replace adminhtml and frontend urls files included through pagebuilder widget preview module or other solutions.
#### Fixed
- Fix undefined variable $children in importTemplateChildren when no files match the pattern
- Add return type hints to SearchResultInterface methods in Grid/Collection

### 1.6.2
### Updated
- Add "repeatable_" prefixed widget fields management downloading media files during export.

### 1.6.1
- Re-add custom ACL for import/export template functionalities fixing issue #7

### 1.6.0
- Fix import issue for missing folders on pub/media, fix issues #7, #6, #5, #4, #3

### 1.5.3
#### Fixed
- Fix issue #1 for error generated saving configurations with empty dropbox settings at first install.

### 1.5.2
#### Fixed
- Fix error for template sync for credentials containing refresh_token 

### 1.5.0
#### Fixed
- Fix Ui/Ux for credentials config and documentation related to it

### 1.4.1
#### Fixed
- Fix error on config mapping for remote templates async save

### 1.4.0
#### Updated
- Add remote templates synchronization by cron on configuration save

### 1.1.0
#### Updated
- Manage remote dropbox storage sync through webhooks using listFolder API cursors. See: https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-get_latest_cursor


### 1.1.0
#### Updated
- Manage remote dropbox storage sync through webhooks using listFolder API cursors. See: https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-get_latest_cursor

### 1.0.0
#### Updated
- Add adminhtml ui management for remote templates import from dropbox

### 0.2.3
#### Updated
- Export template now consider also annidated children cms blocks

### 0.2.2
#### Updated
- Centralize export template to archive file into one single method

### 0.2.1
#### Fixed
- Fixed module composer.json file adding missing version
#### Updated 
- Export template method grouped inside a main export method specified by service contract

### 0.2.0
#### Added
- First beta release
- Template management Model and import/export console commands are now available

### 0.1.0
#### Added
- First Commit

## Recent Versions

| Version | Released |
|---|---|
| 1.8.1 | 2026-05-18 |
| 1.8.0 | 2026-04-29 |
| 1.7.1 | 2026-04-29 |
| 1.7.0 | 2026-04-16 |
| 1.6.3 | 2026-03-12 |
| 1.6.2 | 2025-10-10 |
| 1.6.1 | 2025-10-08 |
| 1.6.0 | 2025-10-04 |
| 1.5.3 | 2025-06-04 |
| 1.5.2 | 2025-03-27 |

Showing 10 of 22 versions. Full release history on https://packagento.com/mage-os/module-page-builder-template-import-export.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| ext-zip | * |
| magento/module-page-builder | * |
| php | ~8.1.0\|\|~8.2.0\|\|~8.3.0\|\|~8.4.0\|\|~8.5.0 |
| spatie/dropbox-api | ^1.22 |

### Require (dev)

| Package | Constraint |
|---|---|
| phpunit/phpunit | ^9.5 |

## Quality

Latest release (1.8.1) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | Pass |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Fail | 82 | 7 errors, 75 warnings (ruleset: Magento2) — 15 auto-fixable with phpcbf |
| PHPMD | Warning | 23 | 23 rule violations (UnusedFormalParameter:7, IfStatementAssignment:4, CyclomaticComplexity:3, UnusedLocalVariable:3, ExcessiveParameterList:2) |
| Cpd | Pass | 0 |  |
| Composer validate | Info | 1 | valid; 1 advisory note (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 32 | 32 | – | – |
| 2.4.8 | – | 32 | 32 | – |
| 2.4.9 | – | – | 32 | 32 |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["mage-os/module-page-builder-template-import-export"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

mage-os is a Magento 2 vendor on Packagento. See https://packagento.com/mage-os.md for their full catalogue.

