3

I've tried to get video on product page on other place not on gallery. But i can't retrieve it. I've seen it stored on catalog_product_entity_media_gallery_value_video

I want to get it proper not direct query. anybody knows proper way?

6

I suggest you to use $product->getMediaGalleryImages()

$galleryImages = $product->getMediaGalleryImages();
if ($galleryImages) {
    foreach ($galleryImages as $image) {
        $imageData = $image->getData();

        // Check media type
        if (isset($imageData['media_type']) && $imageData['media_type'] == 'external-video') {
            // Your code here
        }
    }
}
  • 2
    Great. Only 1 changes condition should be $imageData['media_type'] == 'external-video' instead of $imageData['media_type'] == 'external_video' – Kul May 30 '17 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.