Adapter/PlentymarketsAdapter/ResponseParser/Product/Image/ImageResponseParser.php
public function parseImage(array $entry, array $texts, array &$result)
    {
        try {
            if (!empty($entry['names'][0]['name'])) {
                $name = $entry['names'][0]['name'];
            } else {
                $name = $texts[0]['name1'];
            }

            $alternate = $name;
            if (!empty($entry['names'][0]['alternate'])) {
                $alternate = $entry['names'][0]['alternate'];
            }

            $media = $this->mediaResponseParser->parse([
                'mediaCategory' => MediaCategoryHelper::PRODUCT,
                'id' => $entry['id'],
                'link' => $entry['url'],
                'filename' => $entry['cleanImageName'],
                'name' => $name,
                'hash' => $entry['md5Checksum'],
                'alternateName' => $alternate,
                'translations' => $this->getMediaTranslations($entry, $texts),
            ]);

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

            $linkedShops = array_filter($entry['availabilities'], function (array $availabilitiy) {
                return $availabilitiy['type'] === 'mandant';
            });

            $shopIdentifiers = array_map(function ($shop) {
                $shopIdentity = $this->identityService->findOneBy([
                    'adapterIdentifier' => (string) $shop['value'],
                    'adapterName' => PlentymarketsAdapter::NAME,
                    'objectType' => Shop::TYPE,
                ]);

                if (null === $shopIdentity) {
                    return null;
                }

                return $shopIdentity->getObjectIdentifier();
            }, $linkedShops);

            $image = new Image();
            $image->setMediaIdentifier($media->getIdentifier());
            $image->setShopIdentifiers(array_filter($shopIdentifiers));
            $image->setPosition((int) $entry['position']);
            $image->setName($name);
            $image->setTranslations($media->getTranslations());

            return $image;
        } catch (Exception $exception) {
            $this->logger->notice('error when parsing product image', [
                'id' => $entry['id'],
                'url' => $entry['url'],
            ]);
        }

        return null;
    }
public function parseImage(array $entry, array $texts, array &$result)
    {
        try {
            if (!empty($entry['names'][0]['name'])) {
                $name = $entry['names'][0]['name'];
            } else {
                $name = $texts[0]['name1'];
            }

            $alternate = $name;
            if (!empty($entry['names'][0]['alternate'])) {
                $alternate = $entry['names'][0]['alternate'];
            }

            $media = $this->mediaResponseParser->parse([
                'mediaCategory' => MediaCategoryHelper::PRODUCT,
                'id' => $entry['id'],
                'link' => $entry['url'],
                'filename' => $entry['cleanImageName'],
                'name' => $name,
                'hash' => $entry['md5Checksum'],
                'alternateName' => $alternate,
                'translations' => $this->getMediaTranslations($entry, $texts),
            ]);

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

            $linkedShops = array_filter($entry['availabilities'], function (array $availabilitiy) {
                return $availabilitiy['type'] === 'mandant';
            });

            $shopIdentifiers = array_map(function ($shop) {
                $shopIdentity = $this->identityService->findOneBy([
                    'adapterIdentifier' => (string) $shop['value'],
                    'adapterName' => PlentymarketsAdapter::NAME,
                    'objectType' => Shop::TYPE,
                ]);

                if (null === $shopIdentity) {
                    return null;
                }

                return $shopIdentity->getObjectIdentifier();
            }, $linkedShops);

            $image = new Image();
            $image->setMediaIdentifier($media->getIdentifier());
            $image->setShopIdentifiers(array_filter($shopIdentifiers));
            $image->setPosition((int) $entry['position']);
            $image->setName($name);
            $image->setTranslations($media->getTranslations());

            return $image;
        } catch (Exception $exception) {
            $this->logger->notice('error when parsing product image', [
                'id' => $entry['id'],
                'url' => $entry['url'],
            ]);
        }

        return null;
    }
public function parseImage ( array $ entry , array $ texts , array & $ result ) { try { if ( ! empty ( $ entry [ 'names' ] [ 0 ] [ 'name' ] ) ) { $ name = $ entry [ 'names' ] [ 0 ] [ 'name' ] ; } else { $ name = $ texts [ 0 ] [ 'name1' ] ; } $ alternate = $ name ; if ( ! empty ( $ entry [ 'names' ] [ 0 ] [ 'alternate' ] ) ) { $ alternate = $ entry [ 'names' ] [ 0 ] [ 'alternate' ] ; } $ media = $ this -> mediaResponseParser -> parse ( [ 'mediaCategory' => MediaCategoryHelper :: PRODUCT , 'id' => $ entry [ 'id' ] , 'link' => $ entry [ 'url' ] , 'filename' => $ entry [ 'cleanImageName' ] , 'name' => $ name , 'hash' => $ entry [ 'md5Checksum' ] , 'alternateName' => $ alternate , 'translations' => $ this -> getMediaTranslations ( $ entry , $ texts ) , ] ) ; $ result [ $ media -> getIdentifier ( ) ] = $ media ; $ linkedShops = array_filter ( $ entry [ 'availabilities' ] , function ( array $ availabilitiy ) { return $ availabilitiy [ 'type' ] === 'mandant' ; } ) ; $ shopIdentifiers = array_map ( function ( $ shop ) { $ shopIdentity = $ this -> identityService -> findOneBy ( [ 'adapterIdentifier' => ( string ) $ shop [ 'value' ] , 'adapterName' => PlentymarketsAdapter :: NAME , 'objectType' => Shop :: TYPE , ] ) ; if ( null === $ shopIdentity ) { return null ; } return $ shopIdentity -> getObjectIdentifier ( ) ; } , $ linkedShops ) ; $ image = new Image ( ) ; $ image -> setMediaIdentifier ( $ media -> getIdentifier ( ) ) ; $ image -> setShopIdentifiers ( array_filter ( $ shopIdentifiers ) ) ; $ image -> setPosition ( ( int ) $ entry [ 'position' ] ) ; $ image -> setName ( $ name ) ; $ image -> setTranslations ( $ media -> getTranslations ( ) ) ; return $ image ; } catch ( Exception $ exception ) { $ this -> logger -> notice ( 'error when parsing product image' , [ 'id' => $ entry [ 'id' ] , 'url' => $ entry [ 'url' ] , ] ) ; } return null ; }
@param array $entry
@param array $texts
@param array $result

@return null|Image
@param array $entry @param array $texts @param array $result