I'm working in catalog_category_view.xml and Magento_Catalog/templates/product/list.phtml, trying to move the "Add to Wishlist" button to the top of each product item while keeping the compare button with Add to Cart.

How might I accomplish this? I can reposition them as a pair (by getting the 'addto' child block, but I've been unable to render them independently.


So rather than moving each button, I ended up adding a second Wishlist button manually in Magento_Catalog/templates/product/list.phtml like so:

    <div data-role="add-to-links" class="actions-secondary"<?= strpos($pos, $viewMode . '-secondary') ? $position : '' ?>>
      <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()): ?>
         <a href="#"
            class="action towishlist"
            title="<?php echo $block->escapeHtml(__('Add to Wish List')); ?>"
            aria-label="<?php echo $block->escapeHtml(__('Add to Wish List')); ?>"
            data-post='<?php /* @escapeNotVerified */ echo $block->getAddToWishlistParams($_product); ?>'
               <span><?php /* @escapeNotVerified */ echo __('Add to Wish List') ?></span>
      <?php endif; ?>

Then I removed the original Wishlist button:

<referenceBlock name="category.product.addto.wishlist" remove="true" />

|improve this answer|||||

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.