I want to add new container only for group products in Frontend.

enter image description here

Above Screenshot is group product's view page of my magento frontend.

In above Screenshot,I want to add that container Div below reviews container.

  • Do you need a tab next to reviews or another div entirely after reviews? – Purushotam Sangroula Dec 29 '17 at 14:36
  • Did you try my code? If you do not know how to implement it I'll make it more detailed. – Purushotam Sangroula Dec 31 '17 at 14:47
  • I need another div entirely after reviews Anime. – Nagaraj Juro Jan 2 '18 at 5:53

To do this you have to follow this procedure.

1. Override Magento_Catalog::product/view/details.phtml

First create a module inside which create a layout file /app/code/YourVendor/YourModule/view/frontend/layout/catalog_product_view.xml

<?xml version="1.0"?>
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <referenceBlock name="product.info.details">  
       <action method="setTemplate"> 
           <argument name="template" xsi:type="string">YourVendor_YourModule::details.phtml</argument>

2. Create your details.phtml at location /app/code/YourVendor/YourModule/view/frontend/templates/details.phtml

Make sure you copy whole code from core file and make necessary changes like adding your own div.

 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.

// @codingStandardsIgnoreFile

<?php if ($detailedInfoGroup = $block->getGroupChildNames('detailed_info', 'getChildHtml')):?>
    <div class="product info detailed">
        <?php $layout = $block->getLayout(); ?>
        <div class="product data items" data-mage-init='{"tabs":{"openedState":"active"}}'>
            <?php foreach ($detailedInfoGroup as $name):?>
                    $html = $layout->renderElement($name);
                    if (!trim($html)) {
                    $alias = $layout->getElementAlias($name);
                    $label = $block->getChildData($alias, 'title');
                <div class="data item title"
                     aria-labeledby="tab-label-<?php /* @escapeNotVerified */ echo $alias;?>-title"
                     data-role="collapsible" id="tab-label-<?php /* @escapeNotVerified */ echo $alias;?>">
                    <a class="data switch"
                       href="#<?php /* @escapeNotVerified */ echo $alias; ?>"
                       id="tab-label-<?php /* @escapeNotVerified */ echo $alias;?>-title">
                        <?php /* @escapeNotVerified */ echo $label; ?>
                <div class="data item content" id="<?php /* @escapeNotVerified */ echo $alias; ?>" data-role="content">
                    <?php /* @escapeNotVerified */ echo $html; ?>
            <?php endforeach;?>
<?php endif; ?>
<!--now on goes my logic to add a div for grouped product. -->
<?php if($block->getProduct()->getData('type_id')=='grouped'): ?>
    <div id='custom_block'>
        <h2>This is my added div.</h2>
<?php endif; ?>

3. Output You can see that my div is seen only for grouped product. enter image description here

|improve this answer|||||
  • Thank u so much Anime. It was very useful to me. But can i do this inside "module-grouped-product" module instead of create new module.? – Nagaraj Juro Jan 2 '18 at 6:02
  • Hello nagaraj, you must not write code in core folders, it is bad practice , make your own module. It is an easy task. – Purushotam Sangroula Jan 2 '18 at 6:07
  • @PurushotamSangroula, awesome. is there have any options to add a custom block next to add to cart button? – senthil Jan 30 '19 at 4:54
  • @senthil Yes, there is, thank you for your appreciation – Purushotam Sangroula Jan 30 '19 at 12:37

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.