# Import/Export Plugin Service nutzen \[ERLEDIGT\]

**URL:** https://forum.shopware.com/t/import-export-plugin-service-nutzen-erledigt/58225
**Category:** Programmierung
**Created:** [23. Februar 2019 um 20:07 UTC](https://forum.shopware.com/t/import-export-plugin-service-nutzen-erledigt/58225 "2019-02-23T20:07:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![hbee](https://avatars.discourse-cdn.com/v4/letter/h/f08c70/32.png) [@hbee](https://forum.shopware.com/u/hbee)
#### Post date: [23. Februar 2019 um 20:07 UTC](https://forum.shopware.com/t/import-export-plugin-service-nutzen-erledigt/58225/1 "2019-02-23T20:07:35Z")

</div>

hi, möchte in einem Plugin den Service aus dem Import/Export Plugin nutzen. mit folgendem Code importiere ich mir eine Datei:

```
            //get file size
            $inputFile = Shopware()->DocPath() . $csvFilePath;

            $profileId = Shopware()->Db()->fetchOne("SELECT id FROM s_import_export_profile WHERE name=?",array($profileName));

            $unprocessedFiles = [];
            $postData = [
                'type' => 'import',
                'profileId' => (int) $profileId,
                'importFile' => $inputFile,
                'sessionId' => $sessionId,
                'limit' => [],
                'format' => pathinfo($inputFile, PATHINFO_EXTENSION)
            ];

            /** @var ImportService $importService */
            $importService = SHopware()->Container()->get('swag_import_export.import_service');

            try {
                $resultData = $importService->import($postData, $unprocessedFiles, $inputFile);
                $result =[
                    'success' => true,
                    'data' => $resultData,
                ];
            } catch (\Exception $e) {
                $result = [
                    'success' => false,
                    'msg' => $e->getMessage(),
                ];
            }

```

Problem hat sich erledigt. Fehler lag woanders.
