0

On customer account I only want to show just 5 items of wishlist. How can I do this ? item.phtml is

<div class="products-grid wishlist">
    <?php $iterator = 1; ?>
    <?php if (count($block->getItems())): ?>
    <ol class="product-items">
        <?php foreach ($block->getItems() as $item): ?>
        <?php /* @escapeNotVerified */ echo($iterator++ == 1) ? '<li data-row="product-item" class="product-item" id="item_' . $item->getId() . '">' : '</li><li class="product-item" id="item_' . $item->getId() . '">' ?>
            <div class="product-item-info">
                <?php foreach ($columns as $column): ?>
                    <?php $column->setItem($item); echo $column->toHtml($item);?>
                <?php endforeach; ?>
            </div>
            <div style="clear: both"></div>
        <?php echo($iterator == count($block->getItems())+1) ? '</li>' : '' ?>
        <?php endforeach; ?>
    </ol>
    <?php else: ?>
        <div class="message info empty">
            <span><?php /* @escapeNotVerified */ echo __('This Wish List has no Items');?></span>
        </div>
    <?php endif; ?>
</div>

<?php foreach ($columns as $column): ?>
    <?php echo $column->getAdditionalHtml();?>
<?php endforeach; ?>
  • 1
    Do you want to show only 5 items or want to show pagination for more than 5 items? – Jaimin Sutariya Feb 20 '18 at 8:26
  • @JaiminSutariya I want to show only 5 items. – ephemeral Feb 20 '18 at 10:19
1
<div class="products-grid wishlist">
    <?php $iterator = 1; ?>
    <?php if (count($block->getItems())): ?>
    <ol class="product-items">
        <?php foreach ($block->getItems() as $item): ?>
        <?php /* @escapeNotVerified */ echo($iterator++ == 1) ? '<li data-row="product-item" class="product-item" id="item_' . $item->getId() . '">' : '</li><li class="product-item" id="item_' . $item->getId() . '">' ?>
            <div class="product-item-info">
                <?php foreach ($columns as $column): ?>
                    <?php $column->setItem($item); echo $column->toHtml($item);?>
                <?php endforeach; ?>
            </div>
            <div style="clear: both"></div>
        <?php echo($iterator == count($block->getItems())+1) ? '</li>' : '' ?>
        <?php if($iterator > 5): break; ?>
        <?php endforeach; ?>
    </ol>
    <?php else: ?>
        <div class="message info empty">
            <span><?php /* @escapeNotVerified */ echo __('This Wish List has no Items');?></span>
        </div>
    <?php endif; ?>
</div>

<?php foreach ($columns as $column): ?>
    <?php echo $column->getAdditionalHtml();?>
<?php endforeach; ?>
  • is this tested ? – ephemeral Feb 20 '18 at 10:45
  • No its not tested, but it should work. Let me know if you face any issue with the code. – Jaimin Sutariya Feb 20 '18 at 11:12

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.