public function handle(CommandInterface $command)
    {
        /**
         * @var Manufacturer $manufacturer
         */
        $manufacturer = $command->getPayload();

        $params = [
            'name' => $manufacturer->getName(),
        ];

        if (null !== $manufacturer->getLink()) {
            $params['link'] = $manufacturer->getLink();
        }

        if (null !== $manufacturer->getLogoIdentifier()) {
            $mediaIdentity = $this->identityService->findOneBy([
                'objectIdentifier' => (string) $manufacturer->getLogoIdentifier(),
                'objectType' => Media::TYPE,
                'adapterName' => ShopwareAdapter::NAME,
            ]);

            if (null !== $mediaIdentity) {
                $params['image'] = [
                    'mediaId' => $mediaIdentity->getAdapterIdentifier(),
                ];
            }
        }

        $identity = $this->identityService->findOneBy([
            'objectIdentifier' => (string) $manufacturer->getIdentifier(),
            'objectType' => Manufacturer::TYPE,
            'adapterName' => ShopwareAdapter::NAME,
        ]);

        if (null === $identity) {
            $existingManufacturer = $this->findExistingManufacturer($manufacturer);

            if (null !== $existingManufacturer) {
                $identity = $this->identityService->insert(
                    (string) $manufacturer->getIdentifier(),
                    Manufacturer::TYPE,
                    (string) $existingManufacturer['id'],
                    ShopwareAdapter::NAME
                );
            }
        }

        if ($identity) {
            try {
                $this->resource->getOne($identity->getAdapterIdentifier());
            } catch (ManufacturerNotFoundException $exception) {
                $this->identityService->remove($identity);

                $identity = null;
            }
        }

        if (null === $identity) {
            $manufacturerModel = $this->resource->create($params);

            $this->identityService->insert(
                (string) $manufacturer->getIdentifier(),
                Manufacturer::TYPE,
                (string) $manufacturerModel->getId(),
                ShopwareAdapter::NAME
            );
        } else {
            $manufacturerModel = $this->resource->update($identity->getAdapterIdentifier(), $params);
        }

        $this->attributePersister->saveManufacturerAttributes(
            $manufacturerModel,
            $manufacturer->getAttributes()
        );

        return true;
    }
public function handle(CommandInterface $command)
    {
        /**
         * @var Manufacturer $manufacturer
         */
        $manufacturer = $command->getPayload();

        $params = [
            'name' => $manufacturer->getName(),
        ];

        if (null !== $manufacturer->getLink()) {
            $params['link'] = $manufacturer->getLink();
        }

        if (null !== $manufacturer->getLogoIdentifier()) {
            $mediaIdentity = $this->identityService->findOneBy([
                'objectIdentifier' => (string) $manufacturer->getLogoIdentifier(),
                'objectType' => Media::TYPE,
                'adapterName' => ShopwareAdapter::NAME,
            ]);

            if (null !== $mediaIdentity) {
                $params['image'] = [
                    'mediaId' => $mediaIdentity->getAdapterIdentifier(),
                ];
            }
        }

        $identity = $this->identityService->findOneBy([
            'objectIdentifier' => (string) $manufacturer->getIdentifier(),
            'objectType' => Manufacturer::TYPE,
            'adapterName' => ShopwareAdapter::NAME,
        ]);

        if (null === $identity) {
            $existingManufacturer = $this->findExistingManufacturer($manufacturer);

            if (null !== $existingManufacturer) {
                $identity = $this->identityService->insert(
                    (string) $manufacturer->getIdentifier(),
                    Manufacturer::TYPE,
                    (string) $existingManufacturer['id'],
                    ShopwareAdapter::NAME
                );
            }
        }

        if ($identity) {
            try {
                $this->resource->getOne($identity->getAdapterIdentifier());
            } catch (ManufacturerNotFoundException $exception) {
                $this->identityService->remove($identity);

                $identity = null;
            }
        }

        if (null === $identity) {
            $manufacturerModel = $this->resource->create($params);

            $this->identityService->insert(
                (string) $manufacturer->getIdentifier(),
                Manufacturer::TYPE,
                (string) $manufacturerModel->getId(),
                ShopwareAdapter::NAME
            );
        } else {
            $manufacturerModel = $this->resource->update($identity->getAdapterIdentifier(), $params);
        }

        $this->attributePersister->saveManufacturerAttributes(
            $manufacturerModel,
            $manufacturer->getAttributes()
        );

        return true;
    }
{@inheritdoc}

@param TransferObjectCommand $command