Limiting the number of featured OpenCart products

In Opencart 2, a standard theme, in the product card there is an output of recommended products, below the description of the main product. To limit the number of recommended products displayed, you need to slightly tweak the cycle. Approximately line 453, I will insert with a piece of code to make it clearer

      <?php if (($column_left && $column_right) && (($i+1) % 2 == 0)) { ?>
            <div class="clearfix visible-md visible-sm"></div>
      <?php } elseif (($column_left || $column_right) && (($i+1) % 3 == 0)) { ?>
            <div class="clearfix visible-md"></div>
      <?php } elseif (($i+1) % 4 == 0) { ?>
            <div class="clearfix visible-md"></div>
      <?php } ?>
      <?php $i++; //нам нужна эта строка ?>
<?php } ?>
</div>
<?php } ?>
<?php if ($tags) { ?>

Add to this line a condition for the number of products already displayed

<?php $i++; if ($i == 4) break; ?>

In this case, as soon as the number of displayed recommended products is 4, the cycle will be interrupted and we will have 4 recommended products on the page.

Простий текст

  • Не дозволено жодних HTML теґів.
  • Рядки й абзаци переносяться автоматично.
  • Адреси вебсторінок та адреси електронної пошти автоматично перетворюються у посилання.
Код мови коментаря.