Dependencies between Export Adapters
In some cases, it is necessary for an Export Adapter to depend on another Export Adapter. For example, a product import initially requires the relational product attributes.
For this purpose, the abstract Adapter class of the Shopware-Connector-Bundle provides the method getDependentAdapters. The return value of this method expects a list of strings representing the dependent adapter keys.
The dependent adapters are automatically processed together with this information.
In the export mask, the dependent adapters are automatically selected and locked when an adapter is checked. Dependencies of dependent adapters are taken into account as well. The lock is released as soon as no checked adapter requires the dependent adapter anymore. Adapters that are hidden via hide_export_mask are not displayed in the export mask, but are still processed together.
Example
config/packages/shopware_connector.yaml
twocream_shopware_connector:
export_targets:
- key: shop
target_type: shopware
has_delta_management: true
export_directory: '/NFS/transfer/from-pimcore/to-shop/json/'
asset_domain: 'https://cdn.my-company.tld'
asset_directory: '/NFS/transfer/from-pimcore/to-shop/assets/'
reporting:
from: 'noreply@my-company.tld'
reply_to: 'noreply@my-company.tld'
import_mail_subject: "[Shopware-Connector] Pimcore-Export to Shop"
export_mail_subject: "[Shopware-Connector] Shopware-Import to Shop"
adapters:
- key: 'products'
source_folder_ids:
- '123'
- key: 'attributes'
hide_export_mask: true
source_folder_ids:
- '456'
- key: 'attribute-values'
hide_export_mask: true
source_folder_ids:
- '456'
language_mapping:
de: 'de_DE'
en: 'en_GB'
src/Components/Export/Adapters/Product/ProductAdapter.php
<?php
namespace App\Components\Export\Adapters\Product;
use Twocream\ShopwareConnectorBundle\Transformer\Adapter\ArrayAdapter\ArrayAdapterAbstract;
class ProductAdapter extends ArrayAdapterAbstract
{
// ...
public function getDependentAdapters(): array
{
return ['attributes', 'attribute-values', static::getPackageName()];
}
// ...
}
Summary
In this example, the products adapter depends on the attributes and attribute-values adapters.
The attributes and attribute-values adapters are thus automatically processed together when products is selected. The own package name at the end of the list ensures that products is processed after the dependent adapters – without it, products is processed before them. The ProductAdapterAbstract already defines this list.