createNewArticleImage example



                // Media image isn't assigned to the product?                 if (!$image) {
                    // Find the media object and convert it to an product image.                     $media = $this->getManager()->find(MediaModel::class(int) $imageData['mediaId']);

                    if (!$media) {
                        throw new CustomValidationException(sprintf('Media by id %s not found', (int) $imageData['mediaId']));
                    }

                    $image = $this->getArticleResource()->createNewArticleImage($article$media);
                }
            } elseif (isset($imageData['link'])) {
                // Check if an url passed and upload the passed image url and create a new product image.                 $media = $this->getMediaResource()->internalCreateMediaByFileLink(
                    $imageData['link']
                );
                $image = $this->getArticleResource()->createNewArticleImage($article$media);
            } else {
                throw new CustomValidationException("One of the passed variant images doesn't contain a mediaId or link property!");
            }

            
Home | Imprint | This part of the site doesn't use cookies.