1

How do I edit and change Magento 2 grouped products page? I wish to be able to add more table cells on the page so I can add more information that I need to show from each product in the grouped products. Unfortunately, it seems I'm missing something very important to be able to do this.

Here's what iv done so far:

Copied the

magento/module_grouped_product/view/frontend/templates/product/view/type/grouped.phtml

and created a new folder in

theme/Magento_Grouped_Product/view/frontend/templates/product/view/type

Iv also included the view/type/default.phtml and layout/catalog_product_view_type_grouped.xml in my theme.

After copying these files I tested the grouped.phtml and added a new <th> with just a text TEST and ran setup:upgrade and setup:static-content:deploy, to ensure the updates would get loaded, but nothing has changed. Have I copied the wrong file(s) to my theme or done the whole process wrong?

1
  • check my answer it will help you, we do not need to create view/frontend folder in our theme.
    – kunj
    Commented May 24, 2018 at 12:05

3 Answers 3

0

Try this:

Create new folders in your theme with Magento_GroupedProduct/templates/product/view/type/.

Paste PHTML file like grouped.phtml.

After that you need to run only php bin/magento cache:flush

8
  • Tried it but no help either. Could it be that the problem lies somewhere else?
    – J.Douh
    Commented May 24, 2018 at 12:24
  • have you selected your theme from admin?
    – kunj
    Commented May 24, 2018 at 12:26
  • Yes the theme is already in place and working as it should mostly. Its just that as explained earlier I need to change the grouped products layout so I may bring more data from the product to the frontpage and for that I need more table cells to build it.
    – J.Douh
    Commented May 24, 2018 at 12:33
  • Is there any module for that? Actually, I have tried same with my sample Magento 2 and it is working for me.
    – kunj
    Commented May 24, 2018 at 12:36
  • Didn't find any extra modules and I tried the changes but no help. Any other ideas what could be causing this? Ps. Does it affect the changes in anyway that this is a multistore? This theme is only in use with the store number 2 I'm trying to change.
    – J.Douh
    Commented May 24, 2018 at 12:47
0

You need to create folder like, Magento_GroupedProduct inside the theme,

app/design/frontend/{Vendorname}/{themename}/Magento_GroupedProduct/templates/product/view/type/default.phtml

Now clear cache and check your changes.

4
  • So its not Magento_Grouped_Product, but Magento_GroupedProduct? Also a second question, do I make the changes to default.phtml and not in the grouped.phtm, because grouped.phtml seems to have the actual content I would want to change compared to default.html which only has the quantity messages.
    – J.Douh
    Commented May 24, 2018 at 11:19
  • You can change any files related to your changes based on your requirement. Yes Module name must be Magento_GroupedProduct Commented May 24, 2018 at 11:24
  • Made the changes, but still no change on the page itself. Any idea what could be causing this issue? I also used the setup:upgrade and setup:static-content:deploy to ensure it's not because of them that it isnt working.
    – J.Douh
    Commented May 24, 2018 at 11:33
  • i have updated my code. please remove view/frontend folder from previous path. Commented May 24, 2018 at 12:35
0

Try this one :

Override below file in your theme :

/vendor/magento/module-grouped-product/view/frontend/templates/product/view/type/grouped.phtml

In your theme :

/app/design/frontend/Vendor/YourTheme/Magento_GroupedProduct/templates/product/view/type/grouped.phtml

Replace below table code :

<table class="table data grouped" id="super-product-table">
    <caption class="table-caption"><?= /* @escapeNotVerified */ __('Grouped product items') ?></caption>
    <thead>
    <tr>
        <th class="col item" scope="col" style="width: 30%;"><?= /* @escapeNotVerified */ __('Test') ?></th> 
        <th class="col item" scope="col"><?= /* @escapeNotVerified */ __('Product Name') ?></th>
        <?php if ($_product->isSaleable()): ?>
            <th class="col qty" scope="col"><?= /* @escapeNotVerified */ __('Qty') ?></th>
        <?php endif; ?>
    </tr>
    </thead>

    <?php if ($_hasAssociatedProducts): ?>
    <?php foreach ($_associatedProducts as $_item): ?>
    <tbody>
        <tr>
            <td data-th="<?= $block->escapeHtml(__('Test Content')) ?>" class="col item"  style="width: 30%;">
                Test Content
            </td>
            <td data-th="<?= $block->escapeHtml(__('Product Name')) ?>" class="col item">
                <strong class="product-item-name"><?= $block->escapeHtml($_item->getName()) ?></strong>
                <?php if ($block->getCanShowProductPrice($_product)): ?>
                    <?php if ($block->getCanShowProductPrice($_item)): ?>
                        <?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
                    <?php endif; ?>
                 <?php endif; ?>
            </td>
            <?php if ($_product->isSaleable()): ?>
            <td data-th="<?= $block->escapeHtml(__('Qty')) ?>" class="col qty">
            <?php if ($_item->isSaleable()) : ?>
                <div class="control qty">
                    <input type="number"
                           name="super_group[<?= /* @escapeNotVerified */ $_item->getId() ?>]"
                           data-selector="super_group[<?= /* @escapeNotVerified */ $_item->getId() ?>]"
                           value="<?= /* @escapeNotVerified */ $_item->getQty() * 1 ?>"
                           title="<?= /* @escapeNotVerified */ __('Qty') ?>"
                           class="input-text qty"
                           data-validate="{'validate-grouped-qty':'#super-product-table'}"
                           data-errors-message-box="#validation-message-box"/>
                </div>
            <?php else: ?>
                <div class="stock unavailable" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
                    <span><?= /* @escapeNotVerified */ __('Out of stock') ?></span>
                </div>
            <?php endif; ?>
            </td>
            <?php endif; ?>
        </tr>
        <?php if ($block->getCanShowProductPrice($_product)
            && $block->getCanShowProductPrice($_item)
            && trim($block->getProductPriceHtml(
                $_item,
                \Magento\Catalog\Pricing\Price\TierPrice::PRICE_CODE
            ))): ?>
            <tr class="row-tier-price">
                <td colspan="2">
                    <?= $block->getProductPriceHtml(
                        $_item,
                        \Magento\Catalog\Pricing\Price\TierPrice::PRICE_CODE
                    ) ?>
                </td>
            </tr>
        <?php endif; ?>
    </tbody>
    <?php endforeach; ?>
    <?php else: ?>
    <tbody>
        <tr>
            <td class="unavailable"
                colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>">
                <?= /* @escapeNotVerified */ __('No options of this product are available.') ?>
            </td>
        </tr>
    </tbody>
    <?php endif; ?>
</table>

I have added one cell in table please review attached screenshot. enter image description here

1
  • @J.Douh is that working for you ? Commented May 29, 2018 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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