Brought similar products, but shows all 20, which I indicated in the admin panel. How can I put a limit on what would be shown, for example, only 5 products, that is, it automatically selects from the selected 5, and not 20
1 answer
Found a solution, someone will help. go to catalog/product/list/related.phtml
and put this code in the right place
<?php $i = 0; ?> <?php foreach($this->getItems() as $_item): ?> <?php if($i++ == 5) break; ?>
while <?php foreach($this->getItems() as $_item): ?>
already in related.phtml
, respectively, simply add <?php $i = 0; ?>
<?php $i = 0; ?>
and <?php if($i++ == 5) break; ?>
<?php if($i++ == 5) break; ?>
, where 5 is the quantity of the displayed goods.
- Bad decision. 1. You need only 5 items and not all of which are added, 2. Use
foreach
instead offor
. You can create a module, inherit its block from the class of this block, and then inherit the '_prepareCollection ()' method and incollection->setPage(0)->setOffset(5)
set offset to 5 and get the same result, but initially with 5th elements. - Naumov
|