PHPackages                             boboldehampsink/import - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. boboldehampsink/import

AbandonedArchivedCraft-plugin

boboldehampsink/import
======================

Import Plugin for Craft CMS

0.8.33(9y ago)17426.8k28[38 issues](https://github.com/boboldehampsink/import/issues)[3 PRs](https://github.com/boboldehampsink/import/pulls)PHP

Since Nov 18Pushed 8y ago14 watchersCompare

[ Source](https://github.com/boboldehampsink/import)[ Packagist](https://packagist.org/packages/boboldehampsink/import)[ RSS](/packages/boboldehampsink-import/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (26)Used By (0)

DEPRECATED - Import plugin for Craft CMS
========================================

[](#deprecated---import-plugin-for-craft-cms)

Plugin that allows you to import data from CSV files.

Deprecated
==========

[](#deprecated)

With the release of Craft 3 on 4-4-2018, this plugin has been deprecated. You can still use this with Craft 2 but you are encouraged to use (and develop) a Craft 3 version. At this moment, I have no plans to do so.

Usage
=====

[](#usage)

Importing data is a two step process:

Step 1. Select import options

- Choose the type of element to import (Category, Entry, or User)
- Select the corresponding category group, section, entry type, or user group
- Select the Import Behavior:
    - Append Data — Will add new categories, entries, or users.
    - Replace Data — Will update data for existing matched categories, entries, or users.
    - Delete Data — Will delete data for existing matched categories, entries, or users.

Step 2. Map CSV data

- Map the destination fields for the CSV data.
- Select which fields will be used as criteria to match existing records to replace (update) or delete data.

And import!

Features
========

[](#features)

- Import Entries, Users and Categories
- Map CSV columns onto Fields
- Append, replace or delete data
    - When replacing or deleting, you can build your own criteria for finding
- Has a hook "registerImportOperation" to parse special field type inputs if you want.
- Has a hook "registerImportOptionPaths" to allow special field types to have a custom option (or options) in the mapping select menu.
- Has a hook "modifyImportRow" to allow special field types to customize data just before it gets imported.
- Has events "onImportFinish" and "onBeforeImportDelete"
    - These will notify you when the import finishes or wants to delete an element
- Uses the Task service to import while you work on.
- Automatically detects CSV delimiters
- Will connect Entries (also Structures), Categories, Users and Assets by searching for them
- Will send a summary email when the task if finished
- View your import history
- Ability to revert imports

\###Roadmap###

- Import more ElementTypes (Tags, Globals, Assets?) (0.8)
- Support JSON and XML (0.9)

Important:
==========

[](#important)

The plugin's folder should be named "import"

Frequently Asked Questions
==========================

[](#frequently-asked-questions)

- How do I indicate an element field type in the CSV file?
    - Import utilizes "search", so it can be anything that makes it unique
- How would I indicate a multiplicity of element field types in the CSV file?
    - Just separate them by comma
- How should I write my CSVs so parent &amp; child entries/categories work properly?
    - Write it like Ancestor/Child/Entry and connect as "Ancestor". Do note that "Entries in this section have their own URLs" should be checked.
- Do parent entries already need to exist before I import a CSV? Or can they be created form the came CSV import as their child entries?
    - The entry should exist, but if it comes in the row before then it will exist and it will pass.
- Is there an "Export" feature so I can get to data that is more complete in the DB than in my CSV file?
    - No, but there is the "Export" plugin that can be found here:

Screenshots
===========

[](#screenshots)

History [![History](https://raw.githubusercontent.com/boboldehampsink/CraftImportPlugin/gh-pages/images/history.png)](https://raw.githubusercontent.com/boboldehampsink/CraftImportPlugin/gh-pages/images/history.png)

Upload (entries) [![Upload](https://raw.githubusercontent.com/boboldehampsink/CraftImportPlugin/gh-pages/images/entries.png)](https://raw.githubusercontent.com/boboldehampsink/CraftImportPlugin/gh-pages/images/entries.png)

Upload (users) [![Upload](https://raw.githubusercontent.com/boboldehampsink/CraftImportPlugin/gh-pages/images/users.png)](https://raw.githubusercontent.com/boboldehampsink/CraftImportPlugin/gh-pages/images/users.png)

Map fields [![Map](https://raw.githubusercontent.com/boboldehampsink/CraftImportPlugin/gh-pages/images/map.png)](https://raw.githubusercontent.com/boboldehampsink/CraftImportPlugin/gh-pages/images/map.png)

Hooks
=====

[](#hooks)

### modifyImportRow

[](#modifyimportrow)

Manipulate the data as the import is running. You'll be able to tweak your data just before it goes into the database.

This code example is a good starting point:

```
/**
 * Modify data just before importing
 *
 * @param BaseElementModel $element  The current element receiving import data.
 * @param array            $map      Mapping of data between CSV -> Craft fields.
 * @param array            $data     Raw data provided for this row.
 */
public function modifyImportRow($element, $map, $data)
{
    // Map data to fields
    $fields = array_combine($map, $data);

    // Initialize content array
    $content = array();

    // Arrange your content in a way that makes sense for your plugin
    foreach ($fields as $handle => $value) {
        $content[$handle] = $value;
    }

    // Set modified content
    $element->setContentFromPost($content);
}
```

The `foreach` loop is probably where you'll do the most customizing. However, feel free to edit any (or all) of this method to achieve your desired results.

### registerImportOptionPaths

[](#registerimportoptionpaths)

Prep the field mapping before the import is run. This allows you to customize the `` menu option(s) for your field.

When you are mapping your CSV columns to Craft fields, Import let's you choose which field you want to assign your data to. There is a `` menu with a list of Craft fields, and you select the destination for each column.

The purpose of this hook is to give you the opportunity to replace the standard `` tag with something custom. In essence, you are providing a template which contains a custom `` (or multiple options) to handle the data mapping in a way that is more preferable for your field type.

Put this in your main MyPlugin.php file, and edit accordingly:

```
/**
 * For custom field types, replace default  with custom HTML
 *
 * @return array  Mapping between custom field type -> custom  template
 */
public function registerImportOptionPaths()
{
    return array(
        'MyPlugin_MyFieldType' => 'myplugin/customImportOption.html',
    );
}
```

You are being given the opportunity to say "for fields of this type, use my custom template in place of the default `` tag". Make sure your `customImportOption.html` template outputs one or more `` tags... They will be injected into the field select dropdown menu.

In summary:

1. Create a short template to replace the default ``
2. Map that template to your field type with this hook

If you want to dig in the code a little more and see how it works in even greater detail, [check out this chunk of code here...](https://github.com/boboldehampsink/import/blob/00818471336c92d9461e174096a14f3d30b68697/templates/types/entry/_map.twig#L50-L58)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~30 days

Recently: every ~47 days

Total

23

Last Release

3527d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3dd0df0464b4919048281ee42a9210f4323e8f3a78d046067e550992e4a5fb7e?d=identicon)[boboldehampsink](/maintainers/boboldehampsink)

---

Top Contributors

[![MRolefes](https://avatars.githubusercontent.com/u/11159600?v=4)](https://github.com/MRolefes "MRolefes (4 commits)")[![timkelty](https://avatars.githubusercontent.com/u/18329?v=4)](https://github.com/timkelty "timkelty (3 commits)")[![lindseydiloreto](https://avatars.githubusercontent.com/u/5309692?v=4)](https://github.com/lindseydiloreto "lindseydiloreto (2 commits)")[![ianshea](https://avatars.githubusercontent.com/u/673992?v=4)](https://github.com/ianshea "ianshea (1 commits)")[![code418](https://avatars.githubusercontent.com/u/316645?v=4)](https://github.com/code418 "code418 (1 commits)")[![freddietilley](https://avatars.githubusercontent.com/u/3340513?v=4)](https://github.com/freddietilley "freddietilley (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![damiani](https://avatars.githubusercontent.com/u/357312?v=4)](https://github.com/damiani "damiani (1 commits)")

### Embed Badge

![Health badge](/badges/boboldehampsink-import/health.svg)

```
[![Health](https://phpackages.com/badges/boboldehampsink-import/health.svg)](https://phpackages.com/packages/boboldehampsink-import)
```

###  Alternatives

[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k5](/packages/elgg-elgg)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[johnbillion/user-switching

Instant switching between user accounts in WordPress and WooCommerce.

19768.3k2](/packages/johnbillion-user-switching)[rainlab/blog-plugin

Blog plugin for October CMS

17257.7k](/packages/rainlab-blog-plugin)[rainlab/user-plugin

User plugin for October CMS

11954.3k13](/packages/rainlab-user-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
