From c5fcc46d4ad3ed9a16b19b0e01688aa0b9935a0f Mon Sep 17 00:00:00 2001 From: Graham Wharton Date: Tue, 16 Jul 2019 18:08:51 +0100 Subject: [PATCH] Provided fallback GalleryOptions class when argument missing from layout xml file --- .../frontend/templates/product/view/gallery.phtml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/gallery.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/gallery.phtml index 4b33864aef47a..bdb747bf8d721 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/gallery.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/gallery.phtml @@ -12,6 +12,16 @@ ?> getGalleryOptions() === null) { + $block->setData( + 'gallery_options', + \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Catalog\Block\Product\View\GalleryOptions::class) + ); +} + $images = $block->getGalleryImages()->getItems(); $mainImage = current(array_filter($images, function ($img) use ($block) { return $block->isMainImage($img); @@ -45,7 +55,7 @@ $mainImageData = $mainImage ? "data": getGalleryImagesJson() ?>, "options": getGalleryOptions()->getOptionsJson() ?>, "fullscreen": getGalleryOptions()->getFSOptionsJson() ?>, - "breakpoints": getBreakpoints() ?> + "breakpoints": getBreakpoints() ?> } } }