0

How can i display a banner or html content between every 4 products in magento 2?

Like i have 4 products then i have a wide banner where it says, did you know we offer free shipping? or something like that.

0

In you themes list.phtml

<MagentoBase>\app\design\frontend\<Vendor>\<Theme>\Magento_Catalog\templates\product\list.phtml

Replace you logic with ------ ADD HTML CONTENT ADDING LOGIC HERE ------ in below template

   ...
    ...
            <?php $iterator = 1; ?>
            ...
            ...
                <?php foreach ($_productCollection as $_product): ?>
                    <?php /* @escapeNotVerified */ echo($iterator++ == 1) ? '<li class="item product product-item">' : '</li> ------ ADD HTML CONTENT ADDING LOGIC HERE ------<li class="item product product-item">' ?>
                    ...
                    ...
                <?php endforeach; ?>
    ...
    ...
  • Thanks for your reply. I tried this logic, but it breaks, i found it from magento 1 thread. i don't know what to do : <?php if($i % 3 == 0){ ?> <div id="banner"> -- Banner here -- </div> <?php } ?> – Fancyman Jun 1 '17 at 12:27

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.