Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
product_simple_with_media_gallery_entries.php
Go to the documentation of this file.
1 <?php
7 include __DIR__ . '/product_simple_with_full_option_set.php';
8 
13 
19  \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory::class
20 );
21 
25 $imageContentFactory = $objectManager->get(\Magento\Framework\Api\Data\ImageContentInterfaceFactory::class);
27 $testImagePath = __DIR__ .'/magento_image.jpg';
28 $imageContent->setBase64EncodedData(base64_encode(file_get_contents($testImagePath)));
29 $imageContent->setType("image/jpeg");
30 $imageContent->setName("1.jpg");
31 
33 $video->setDisabled(false);
34 //$video->setFile('1.png');
35 $video->setFile('1.jpg');
36 $video->setLabel('Video Label');
37 $video->setMediaType('external-video');
38 $video->setPosition(2);
39 $video->setContent($imageContent);
40 
45  \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryExtensionFactory::class
46 );
48 
53  \Magento\Framework\Api\Data\VideoContentInterfaceFactory::class
54 );
56 $videoContent->setMediaType('external-video');
57 $videoContent->setVideoDescription('Video description');
58 $videoContent->setVideoProvider('youtube');
59 $videoContent->setVideoMetadata('Video Metadata');
60 $videoContent->setVideoTitle('Video title');
61 $videoContent->setVideoUrl('http://www.youtube.com/v/tH_2PFNmWoga');
62 
64 $video->setExtensionAttributes($mediaGalleryEntryExtension);
65 
70  \Magento\Catalog\Api\ProductAttributeMediaGalleryManagementInterface::class
71 );
72 $mediaGalleryManagement->create('simple', $video);
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60