PHPackages                             2lenet/import-bundle - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. 2lenet/import-bundle

ActiveSymfony-bundle[File &amp; Storage](/categories/file-storage)

2lenet/import-bundle
====================

Import data from files (.csv, .xml, ...)

2.0.2(5mo ago)16.7k—0%MITPHPPHP ^8.4

Since Mar 15Pushed 5mo ago7 watchersCompare

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

READMEChangelog (10)Dependencies (18)Versions (18)Used By (0)

ImportBundle - Click And Mortar
===============================

[](#importbundle---click-and-mortar)

Import Bundle can be used to populate entities from flat files (.csv, .xml, etc.)

1. Installation

---

Add package your **`composer.json`** file:

```
"require": {
    ...
    "2lenet/import-bundle": "^1.0"
    ...
}
```

Launch `composer update` to add bundle to your project:

```
composer update 2lenet/import-bundle
```

Add bundle in your **`app/AppKernel.php`** file:

```
$bundles = array(
            ...
            new ClickAndMortar\ImportBundle\ClickAndMortarImportBundle(),
        );
```

2. Configuration

---

Configure bundle with your own entities in your **app/config.yml** file. Example:

```
click_and_mortar_import:
  entities:
    customer_from_pim:
      model: Acme\DemoBundle\Entity\Customer
      repository: AcmeDemoBundle:Customer
      unique_key: id
      mappings:
        id: "ID"
        name: "Name_For_Customer"
        firstname: "FirstName"
        gender: "Sex"
        age: "Age"
        ...
```

You can define multiple imports for a single entity by simply changing the name of the import procedure (eg. add a new part under **entities** with name **customer\_from\_ecommerce**)

**Options available:**

OptionMandatoryExampleCommentmodelYesAcme\\DemoBundle\\Entity\\CustomerModel name in your projectrepositoryYesAcmeDemoBundle:CustomerRepository name for entityunique\_keyNoidAllows entities update from a propertyonly\_updateNofalseIf true, only update existing entities by using unique\_keyimport\_helper\_serviceNoacme.demo.import\_helper.my\_import\_helperExtension point to complete classic mapping data on entity. Service must implements "ImportHelperInterface" interface3. Usage

---

Launch import of file with command:

```
php app/console candm:import /path/of/your/file/customers.csv customer_from_pim
```

**Options available:**

OptionComment--delete-after-importDelete file after import4. Extension

---

You can create your own reader to read other file types.

Create your class (in **YourOrganizationName/YourBundle/Reader/Readers**) and extends **AbstractReader**:

```
