Adapter/ShopwareAdapter/RequestGenerator/Product/ProductRequestGenerator.php
public function generate(Product $product)
    {
        $this->addShippingProfilesAsAttributes($product);

        $shopIdentifiers = array_filter($product->getShopIdentifiers(), function ($identifier) {
            $shopIdentity = $this->identityService->findOneBy([
                'objectIdentifier' => $identifier,
                'objectType' => Shop::TYPE,
                'adapterName' => ShopwareAdapter::NAME,
            ]);

            return null !== $shopIdentity;
        });

        if (empty($shopIdentifiers)) {
            return [];
        }

        $vatIdentity = $this->identityService->findOneBy([
            'objectIdentifier' => $product->getVatRateIdentifier(),
            'objectType' => VatRate::TYPE,
            'adapterName' => ShopwareAdapter::NAME,
        ]);

        if (null === $vatIdentity) {
            throw new InvalidArgumentException('vat rate not mapped - ' . $product->getVatRateIdentifier());
        }

        $manufacturerIdentity = $this->identityService->findOneBy([
            'adapterName' => ShopwareAdapter::NAME,
            'objectType' => Manufacturer::TYPE,
            'objectIdentifier' => $product->getManufacturerIdentifier(),
        ]);

        if (null === $manufacturerIdentity) {
            throw new InvalidArgumentException('manufacturer is missing - ' . $product->getManufacturerIdentifier());
        }

        $propertyData = $this->getPropertyData($product);

        $params = [
            'filterGroupId' => $propertyData['filterGroupId'],
            'propertyValues' => $propertyData['propertyValues'],
            'mainDetail' => [
                'number' => $product->getNumber(),
            ],
            'availableFrom' => $product->getAvailableFrom(),
            'availableTo' => $product->getAvailableTo(),
            'name' => $product->getName(),
            'description' => $product->getMetaDescription(),
            'descriptionLong' => !empty($product->getLongDescription()) ? $product->getLongDescription() : $product->getDescription(),
            'categories' => $this->getCategories($product),
            'seoCategories' => $this->getSeoCategories($product),
            'taxId' => $vatIdentity->getAdapterIdentifier(),
            'notification' => $this->configService->get('item_notification') === 'true' ? 1 : 0,
            'active' => $product->isActive(),
            'highlight' => $this->getHighlightFlag($product),
            'images' => $this->getImages($product),
            'similar' => $this->getLinkedProducts($product),
            'related' => $this->getLinkedProducts($product, LinkedProduct::TYPE_ACCESSORY),
            'metaTitle' => $product->getMetaTitle(),
            'keywords' => $product->getMetaKeywords(),
            'changed' => (new DateTime('now'))->format('Y-m-d H:i:s'),
            'supplierId' => $manufacturerIdentity->getAdapterIdentifier(),
            '__options_categories' => ['replace' => true],
            '__options_seoCategories' => ['replace' => true],
            '__options_similar' => ['replace' => true],
            '__options_related' => ['replace' => true],
            '__options_images' => ['replace' => true],
        ];

        $configuratorSet = $this->configuratorSetRequestGenerator->generate($product);

        if (!empty($configuratorSet)) {
            $params['configuratorSet'] = $configuratorSet;
        }

        return $params;
    }
public function generate(Product $product)
    {
        $this->addShippingProfilesAsAttributes($product);

        $shopIdentifiers = array_filter($product->getShopIdentifiers(), function ($identifier) {
            $shopIdentity = $this->identityService->findOneBy([
                'objectIdentifier' => $identifier,
                'objectType' => Shop::TYPE,
                'adapterName' => ShopwareAdapter::NAME,
            ]);

            return null !== $shopIdentity;
        });

        if (empty($shopIdentifiers)) {
            return [];
        }

        $vatIdentity = $this->identityService->findOneBy([
            'objectIdentifier' => $product->getVatRateIdentifier(),
            'objectType' => VatRate::TYPE,
            'adapterName' => ShopwareAdapter::NAME,
        ]);

        if (null === $vatIdentity) {
            throw new InvalidArgumentException('vat rate not mapped - ' . $product->getVatRateIdentifier());
        }

        $manufacturerIdentity = $this->identityService->findOneBy([
            'adapterName' => ShopwareAdapter::NAME,
            'objectType' => Manufacturer::TYPE,
            'objectIdentifier' => $product->getManufacturerIdentifier(),
        ]);

        if (null === $manufacturerIdentity) {
            throw new InvalidArgumentException('manufacturer is missing - ' . $product->getManufacturerIdentifier());
        }

        $propertyData = $this->getPropertyData($product);

        $params = [
            'filterGroupId' => $propertyData['filterGroupId'],
            'propertyValues' => $propertyData['propertyValues'],
            'mainDetail' => [
                'number' => $product->getNumber(),
            ],
            'availableFrom' => $product->getAvailableFrom(),
            'availableTo' => $product->getAvailableTo(),
            'name' => $product->getName(),
            'description' => $product->getMetaDescription(),
            'descriptionLong' => !empty($product->getLongDescription()) ? $product->getLongDescription() : $product->getDescription(),
            'categories' => $this->getCategories($product),
            'seoCategories' => $this->getSeoCategories($product),
            'taxId' => $vatIdentity->getAdapterIdentifier(),
            'notification' => $this->configService->get('item_notification') === 'true' ? 1 : 0,
            'active' => $product->isActive(),
            'highlight' => $this->getHighlightFlag($product),
            'images' => $this->getImages($product),
            'similar' => $this->getLinkedProducts($product),
            'related' => $this->getLinkedProducts($product, LinkedProduct::TYPE_ACCESSORY),
            'metaTitle' => $product->getMetaTitle(),
            'keywords' => $product->getMetaKeywords(),
            'changed' => (new DateTime('now'))->format('Y-m-d H:i:s'),
            'supplierId' => $manufacturerIdentity->getAdapterIdentifier(),
            '__options_categories' => ['replace' => true],
            '__options_seoCategories' => ['replace' => true],
            '__options_similar' => ['replace' => true],
            '__options_related' => ['replace' => true],
            '__options_images' => ['replace' => true],
        ];

        $configuratorSet = $this->configuratorSetRequestGenerator->generate($product);

        if (!empty($configuratorSet)) {
            $params['configuratorSet'] = $configuratorSet;
        }

        return $params;
    }
{@inheritdoc}