public function parse(array $product)
    {
        $result = [];

        if (empty($product['texts'])) {
            $this->logger->notice('the product has no text fieds and will be skipped', [
                'product id' => $product['id'],
            ]);

            return [];
        }

        $mainVariation = $this->variationHelper->getMainVariation($product['variations']);

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

        $identity = $this->identityService->findOneOrCreate(
            (string) $product['id'],
            PlentymarketsAdapter::NAME,
            Product::TYPE
        );

        $candidatesForProcessing = $this->variationResponseParser->parse($product);

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

        $variations = array_filter($candidatesForProcessing, function (TransferObjectInterface $object) {
            return $object instanceof Variation;
        });

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

        $productObject = new Product();
        $productObject->setIdentifier($identity->getObjectIdentifier());
        $productObject->setName((string) $product['texts'][0]['name1']);
        $productObject->setActive($this->getActive($variations, $mainVariation));
        $productObject->setNumber($this->variationHelper->getMainVariationNumber($mainVariation, $variations));
        $productObject->setBadges($this->getBadges($product));
        $productObject->setShopIdentifiers($this->variationHelper->getShopIdentifiers($mainVariation));
        $productObject->setManufacturerIdentifier($this->getManufacturerIdentifier($product));
        $productObject->setCategoryIdentifiers($this->getCategories($mainVariation));
        $productObject->setDefaultCategoryIdentifiers($this->getDafaultCategories($mainVariation));
        $productObject->setShippingProfileIdentifiers($this->getShippingProfiles($product));
        $productObject->setImages($this->getImages($product, $product['texts'], $result));
        $productObject->setVatRateIdentifier($this->getVatRateIdentifier($mainVariation));
        $productObject->setDescription((string) $product['texts'][0]['shortDescription']);
        $productObject->setLongDescription((string) $product['texts'][0]['description']);
        $productObject->setMetaTitle((string) $product['texts'][0]['name1']);
        $productObject->setMetaDescription((string) $product['texts'][0]['metaDescription']);
        $productObject->setMetaKeywords((string) $product['texts'][0]['keywords']);
        $productObject->setMetaRobots('INDEX, FOLLOW');
        $productObject->setLinkedProducts($this->getLinkedProducts($product));
        $productObject->setProperties($this->getProperties($mainVariation));
        $productObject->setTranslations($this->getProductTranslations($product['texts']));
        $productObject->setAvailableFrom($this->getAvailableFrom($mainVariation));
        $productObject->setAvailableTo($this->getAvailableTo($mainVariation));
        $productObject->setCreatedAt($this->getCreatedAt($mainVariation));
        $productObject->setAttributes($this->getAttributes($product));
        $productObject->setVariantConfiguration($this->getVariantConfiguration($variations));

        $result[$productObject->getIdentifier()] = $productObject;

        $candidatesForProcessing = $this->addProductAttributesToVariation($productObject, $candidatesForProcessing);

        return array_merge($result, $candidatesForProcessing);
    }
public function parse(array $product)
    {
        $result = [];

        if (empty($product['texts'])) {
            $this->logger->notice('the product has no text fieds and will be skipped', [
                'product id' => $product['id'],
            ]);

            return [];
        }

        $mainVariation = $this->variationHelper->getMainVariation($product['variations']);

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

        $identity = $this->identityService->findOneOrCreate(
            (string) $product['id'],
            PlentymarketsAdapter::NAME,
            Product::TYPE
        );

        $candidatesForProcessing = $this->variationResponseParser->parse($product);

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

        $variations = array_filter($candidatesForProcessing, function (TransferObjectInterface $object) {
            return $object instanceof Variation;
        });

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

        $productObject = new Product();
        $productObject->setIdentifier($identity->getObjectIdentifier());
        $productObject->setName((string) $product['texts'][0]['name1']);
        $productObject->setActive($this->getActive($variations, $mainVariation));
        $productObject->setNumber($this->variationHelper->getMainVariationNumber($mainVariation, $variations));
        $productObject->setBadges($this->getBadges($product));
        $productObject->setShopIdentifiers($this->variationHelper->getShopIdentifiers($mainVariation));
        $productObject->setManufacturerIdentifier($this->getManufacturerIdentifier($product));
        $productObject->setCategoryIdentifiers($this->getCategories($mainVariation));
        $productObject->setDefaultCategoryIdentifiers($this->getDafaultCategories($mainVariation));
        $productObject->setShippingProfileIdentifiers($this->getShippingProfiles($product));
        $productObject->setImages($this->getImages($product, $product['texts'], $result));
        $productObject->setVatRateIdentifier($this->getVatRateIdentifier($mainVariation));
        $productObject->setDescription((string) $product['texts'][0]['shortDescription']);
        $productObject->setLongDescription((string) $product['texts'][0]['description']);
        $productObject->setMetaTitle((string) $product['texts'][0]['name1']);
        $productObject->setMetaDescription((string) $product['texts'][0]['metaDescription']);
        $productObject->setMetaKeywords((string) $product['texts'][0]['keywords']);
        $productObject->setMetaRobots('INDEX, FOLLOW');
        $productObject->setLinkedProducts($this->getLinkedProducts($product));
        $productObject->setProperties($this->getProperties($mainVariation));
        $productObject->setTranslations($this->getProductTranslations($product['texts']));
        $productObject->setAvailableFrom($this->getAvailableFrom($mainVariation));
        $productObject->setAvailableTo($this->getAvailableTo($mainVariation));
        $productObject->setCreatedAt($this->getCreatedAt($mainVariation));
        $productObject->setAttributes($this->getAttributes($product));
        $productObject->setVariantConfiguration($this->getVariantConfiguration($variations));

        $result[$productObject->getIdentifier()] = $productObject;

        $candidatesForProcessing = $this->addProductAttributesToVariation($productObject, $candidatesForProcessing);

        return array_merge($result, $candidatesForProcessing);
    }
@param array $product

@return TransferObjectInterface[]