Frequently Asked Questions
How are entity data in Shopware deleted when the object in Pimcore has an active switch?
Both unpublishing and deleting objects in Pimcore trigger a deletion in Shopware during the subsequent export. This assumes that the import module does not suppress the delete function (method: 'canBeDeleted').
However, if an active switch is used in Pimcore, it must be evaluated in the export adapter as follows:
<?php
namespace App\Component\Export\Adapter;
use Twocream\ShopwareConnectorBundle\Transformer\Adapter\ArrayAdapter\ArrayAdapterAbstract;
class VideoAdapter extends ArrayAdapterAbstract
{
public static function getPackageName(): string
{
return 'video';
}
public function getTargetClassName(): string
{
return 'Video';
}
protected function prepare($object): array
{
if (!$object->getStateInformation()) {
return [];
}
// ...
return $serializedData;
}
}
As soon as the 'prepare' method returns an empty array, this signals the deletion of the record. The Pimcore ID and Shopware UUID are automatically recorded for deletion in the export task.
Product adapters (ProductAdapterAbstract) evaluate an active switch in isExportable(), prepare() does not have to be overridden for this (see "Step 4: Variants"). The ProductModule does not delete products but deactivates them (see "What happens if a product is deleted in the source system?").
How do I bundle several adapters into one entry in the export mask?
With a virtual adapter that inherits from GroupAdapterAbstract and lists the bundled adapters in getDependentAdapters() (see "Virtual adapters (groups)").