2

I am using magento 2.0.7 and I want to display the product video/image and product description (in product description tab) in view page.

2

simply render that block and template in detail tab

Add the below line in <magento-root>/app/design/frontend/Vendor/Theme_name/Magento_Catalog/templates/product/view/attribute.phtml before end of div tag

<?php echo $this->getLayout()->createBlock("Magento\Catalog\Block\Product\View\Gallery")->setTemplate("Magento_Catalog::product/view/gallery.phtml")->toHtml(); ?>

The output is look like below may be your styling get different because I do some LESS work for my image view. easy for your reference

  • not working.. js errors Uncaught TypeError: Cannot read property 'returnCurrentImages' of undefined – Magento2 Devloper Dec 3 '18 at 19:05
1

The following tutorial will help you add your Magento product video under the product name programmatically.

First, create "video" attribute as text input.

Jump to the following file.

app/design/frontend/yourpackage/yourtheme/template/catalog/product/view.phtml

and find the following code in the above file.

<div class="product-name">
<h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
</div>

Now insert the following code.

<?php if($_product->getVideo()): ?>

<iframe width="560" height="315" src="http://www.youtube.com/embed/<?php echo $_product->getVideo() ?>" frameborder="0" allowfullscreen></iframe>

<?php endif; ?>

To display the video, you just have to paste the video Unique Identifier into the video attribute field.

0

New tab in product detail page is very easy task with product attribute. Use below steps and check it out.

Step 1. Create Product Attribute

video

.

Step 2. Create file “catalog_product_view.xml” in the app/design/frontend/{vender name}/{theme name}/Magento_Catalog/layout

In the file write the below code:

    <!-- this is code to add new tab start -->
<referenceBlock name="product.info.details">
<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.video" template="product/view/attribute.phtml" group="detailed_info">
<arguments>
<argument name="at_call" xsi:type="string">getVideo</argument>
<argument name="at_code" xsi:type="string">video</argument>
<argument name="css_class" xsi:type="string">video</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">Video</argument>
</arguments>
</block>
</referenceBlock>
<!-- this is code to add new tab end -->

Hope it will work for you.

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.