1

I want to override

"wishlist_index_index.xml"

with some changes.

Default layout output:- enter image description here

Expected output:-

enter image description here

Here I want to move comment div out side "product-item-info" div.

Please let me know the magento2 best practice to achieve this.

1

You can override this file in your custom theme. Because using wishlist_index_index.xml that change is not possible.

vendor/magento/module-wishlist/view/frontend/templates/item/list.phtml

Here

app/design/frontend/Vendor/Theme/Magento_Wishlist/templates/item/list.phtml

Content for this file is..

<?php
/** @var \Magento\Wishlist\Block\Customer\Wishlist\Items $block */
$columns = $block->getColumns();
?>

<div class="products-grid wishlist">
    <?php if (count($block->getItems())) : ?>
    <ol class="product-items">
        <?php foreach ($block->getItems() as $item) : ?>
            <li data-row="product-item" class="product-item" id="item_<?= $block->escapeHtmlAttr($item->getId()) ?>">
                <div class="product-item-info" data-container="product-grid">
                    <?php foreach ($columns as $column) : ?>
                        <?php if($column->getNameInLayout() != 'customer.wishlist.item.inner'): ?>
                            <?= $column->setItem($item)->toHtml();?>
                        <?php endif; ?>
                    <?php endforeach; ?>
                </div>
                <?php echo $block->getLayout()->getBlock('customer.wishlist.item.inner')->setItem($item)->toHtml(); ?>
            </li>
        <?php endforeach; ?>
    </ol>
    <?php else : ?>
        <div class="message info empty">
            <span><?= $block->escapeHtml(__('This Wish List has no Items')) ?></span>
        </div>
    <?php endif; ?>
</div>

<?php foreach ($columns as $column) : ?>
    <?= $column->getAdditionalHtml() ?>
<?php endforeach; ?>

Hope this will help you!

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.