Skip to main content
Version: Next

Customize and Extend

Productsup exports data through an exporter service that extends Datahub File Export's Pimcore\Bundle\DataHubFileExportBundle\Exporter\AbstractExporter. Two exporters ship with the bundle:

  • Pimcore\Bundle\DataHubProductsupBundle\Exporter\Productsup (service ID pimcore.datahub.fileExport.exporter.productsup): used for configurations with a legacy, tree-based schema.
  • Pimcore\Bundle\DataHubProductsupBundle\Exporter\StudioProductsup (service ID pimcore.datahub.productsup.exporter.studioProductsup): used for configurations with a Pimcore Studio, column-based schema. It reads columns through the Studio GridServiceInterface.

Beyond swapping the exporter, Events let you filter items and reshape data or imported orders without replacing the exporter service.

Custom exporter services

To fully control how a configuration is exported, register your own service and either select it per configuration in the Workspaces tab's Custom Export Service field, or make it the bundle-wide default.

Create a service class extending Productsup or StudioProductsup:

<?php

namespace App\DataHubProductsup\Exporter;

use Pimcore\Bundle\DataHubProductsupBundle\Exporter\StudioProductsup;
use Pimcore\Model\DataObject;

class MyStudioProductsup extends StudioProductsup
{
public function getItemData(DataObject\Concrete $object): array|bool
{
$data = parent::getItemData($object);

if ($data === false) {
return false;
}

$data['brand'] = 'Acme';
$data[self::ITEM_FIELDS_FIELD][] = 'brand';

return $data;
}
}
warning

The second line is required. getItemData() records the item's field list in ITEM_FIELDS_FIELD before returning, and execute() stores only the fields listed there (array_intersect_key). A key added after the parent call without also being appended to ITEM_FIELDS_FIELD is silently dropped and never reaches Productsup.

Register it as a public, non-shared service tagged pimcore.datahub.fileExport.exporter:

app.datahub.my-studio-productsup:
class: App\DataHubProductsup\Exporter\MyStudioProductsup
public: true
shared: false
tags:
- { name: "pimcore.datahub.fileExport.exporter" }

The tag is what puts the service into the Custom Export Service dropdown; public: true is required because the service is fetched from the container by id at runtime, and shared: false gives each export run its own instance. Select app.datahub.my-studio-productsup there to use it for a single configuration.

Changing the bundle-wide default

Without a per-configuration override, and for configurations with a legacy tree-based schema, the exporter defaults to pimcore.datahub.fileExport.exporter.productsup. Change it bundle-wide in config.yaml:

pimcore_data_hub_productsup:
defaultExporter: "app.datahub.my-exporter"

This setting has no effect on configurations with a Pimcore Studio, column-based schema. Those always use pimcore.datahub.productsup.exporter.studioProductsup unless a Custom Export Service is set explicitly.

Filtering the exported listing

Override the protected getQueryCondition() method on a custom exporter to restrict which objects are considered for export. It returns the SQL condition applied to the class listing; the inherited implementation builds it from the configuration's workspace paths. To adjust the listing without subclassing, listen for RelevantItemListEvent, and to skip individual items, listen for IsValidExportItemEvent. See Events.