Customize and Extend

There are multiple ways for extending the file export adapter.

It is possible to add additional file types and transmitters (see below) and there are a couple of events that allow to further customize the export.

In addition to that, it is also possible to completely customize the whole exporter by providing a custom exporter service. This gives you full control over the whole export process and allows things like adding custom query conditions for the workspaces etc.

Additional Transmitters

Transmitters are responsible for delivering the file to its desired destination (local directory, remote location, etc.). If you want to add further transmitters just provide a PHP service class like this:

namespace AppBundle\DataHubFileExport\Exporter\Transmitter;

class MyCustomTransmitter extends \Pimcore\Bundle\DataHubFileExportBundle\Exporter\Transmitter\AbstractTransmitter {

    public function execute()
        $exportType  = $this->getExporterType();
        $tmpFile = $exportType->getTmpFile();

        $config = $exportType->getExporter()->getDataHubConfiguration()->getConfiguration();
        $transmitterConfig = $config['deliveryDestination']['transmitter_myCustomTransmitter'];
        var_dump($transmitterConfig); exit;
        //push it somewhere

... and add it as a Service with the tag pimcore.datahub.fileExport.exporter.transmitter

        shared: false
            - { name: "pimcore.datahub.fileExport.exporter.transmitter", type: "myCustomTransmitter" }

For the JavaScript part (custom configuration fields for your transmitter) you can provide a fieldset like follows. If you registered the PHP Service with the type myCustomTransmitter, your id has to be transmitter_myCustomTransmitter (type prefixed with transmitter_). Please make sure that the id naming convention is correct.

pimcoreDataHubFileExportBundlePlugin.transmitter.myCustomTransmitter = function () {
    let id = "transmitter_myCustomTransmitter";
    return {
        xtype: "fieldset",
        title: t("plugin_pimcore_datahub_delivery_destination_transmitter_myCustomTransmitter"),
        width: 600,
        itemId: id,
        defaultType: 'textfield',
        hidden: false,
        items: [{
            fieldLabel: t("plugin_pimcore_datahub_delivery_destination_directory"),
            name: id + ".directory",
            width:  560,
            value: this.getValue('deliveryDestination.'+ id +'.directory')

If you don't need further configuration, you can just define an empty function, so the transmitter shows up in the Delivery type dropdown:

pimcoreDataHubFileExportBundlePlugin.transmitter.myCustomTransmitter = function () {};

Please make sure with bundle priorities, that your Bundle is loaded after the DataHub File Export, otherwise you will get a Javascript error because the variable doesn't exist.

Additional Exporter Types

To add additional exporter types (besides CSV, XML and JSON) just have a look at the existing ones. You can create custom exporter types by just adding additional services add extend the Pimcore\Bundle\DataHubFileExportBundle\Exporter\Type\AbstractExporter class and register them with the tag pimcore.datahub.fileExport.exporter.type.

        shared: false
            - { name: "pimcore.datahub.fileExport.exporter.type", type: "MY_JSON" }

Customize built in Exporter Types/Transmitters

To customize the built in exporter/transmitter you can override the existing services. Please take a look at Service definition of the bundle on how they are defined.

If you want to override the XML exporter type, you could do it like this:

Create your service class e.g:


namespace AppBundle\DataSyndicator\Exporter\Type;

class XML extends \Pimcore\Bundle\DataHubFileExportBundle\Exporter\Type\XML

    protected $itemKey = 'myCustomItemKey';

    protected function writeData($data)
        return parent::writeData($data);

    protected function getExistingData(): array
        return parent::getExistingData(); 

... and override the service definition in your services.yml with:

        class: AppBundle\DataSyndicator\Exporter\Type\XML
        shared: false
            - { name: "pimcore.datahub.fileExport.exporter.type", type: "XML" }

This would just change the XML node item key from item to myCustomItemKey.

Custom exporter services

The exporter service implements and controls the whole export process. The default bundle configuration for the file exporter looks like this. So you can override custom parts if you need it.

    defaultExporter: 'pimcore.datahub.fileExport.exporter.file'

By default, the pimcore.datahub.fileExport.exporter.file service (see settings above) is used to execute the export. You can change the exporter globally (settings above) or per export configuration.

To create a custom exporter service you have to register the class as a public service.


        class: AppBundle\DataSyndicator\Exporter\File
        public: true
        shared: false
            - { name: "pimcore.datahub.fileExport.exporter"}

Please make sure it is public, not shared and tagged as in the sample above!


namespace AppBundle\DataSyndicator\Exporter;

class File extends \Pimcore\Bundle\DataHubFileExportBundle\Exporter\File {

    public function execute($data)
        //do some custom stuff instead of calling the parent
        return parent::execute($data);