質問

Not even sure where to begin with this one. Updated Magento from 2.2 to 2.3, and now when you go to a product page, only the image loads. There's nothing in the body but that and some javascript, then an error:

Uncaught Error: Call to a member function getOptionsJson() on null in /home/vagrant/code/vendor/magento/module-catalog/view/frontend/templates/product/view/gallery.phtml:46

Which is pointing at "options": <?= /* @noEscape */ $block->getGalleryOptions()->getOptionsJson() ?>, but I have absolutely no idea what getGalleryOptions is doing or why it would be null.

役に立ちましたか?

解決

This was raised as an issue on the Magento github and is caused by an incompatibility with custom code in your theme. you will find more info and a solution here

You need to locate in whichever of your third party modules is instantiating an instance of the "\Magento\Catalog\Block\Product\View\Gallery" class in its layout xml files and ensure it is injecting the argument "gallery_options" to the block

他のヒント

                <block class="Magento\Catalog\Block\Product\View\Gallery" name="product.info.media.image" template="product/view/gallery.phtml">
<arguments>
    <argument name="gallery_options" xsi:type="object">Magento\Catalog\Block\Product\View\GalleryOptions</argument>
</arguments>
       <block class="Magento\Catalog\Block\Product\View\Gallery" name="product.info.media.image" template="product/view/gallery.phtml">
         <arguments>
               <argument name="gallery_options" xsi:type="object">Magento\Catalog\Block\Product\View\GalleryOptions</argument>
           </arguments>
     </block>
ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top