Log in
Helper

Compare

Magento\Catalog\Helper\Product\Compare

What it does

This helper class manages the product comparison functionality in Magento 2.

Developers use it to generate URLs for adding/removing products from the compare list, retrieve the collection of compared products, and get the count of items in the comparison.

It handles both logged-in customers and guest visitors, making it essential for implementing product comparison features in themes and custom modules.

Public Methods

  • getListUrl()
  • getPostDataParams()
  • getAddUrl()
  • getAddToWishlistParams()
  • getAddToCartUrl()
  • getRemoveUrl()
  • getPostDataRemove()
  • getClearListUrl()
  • getPostDataClearList()
  • getItemCollection()
  • calculate()
  • getItemCount()
  • hasItems()
  • setAllowUsedFlat()
  • getAllowUsedFlat()
  • setCustomerId()