0

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.

1 Answer 1

0

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); ?>'
             data-action="add-to-wishlist"
             role="button">
               <span><?php /* @escapeNotVerified */ echo __('Add to Wish List') ?></span>
         </a>
      <?php endif; ?>
    </div>

Then I removed the original Wishlist button:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.