Check whether a product is in the wishlist or not

前端 未结 6 977
不思量自难忘°
不思量自难忘° 2021-01-15 02:51

I\'m working on a Magento theme, and I need to build a function that can check to see whether or not a product has been added to the user\'s wishlist.

Magento has a

6条回答
  •  终归单人心
    2021-01-15 03:08

    I'm only getting back to this project now, but I took Daniel Sloof's suggestion, and it worked perfectly using the function below:

    public function isInWishlist($item)
    {
        $_productCollection = Mage::helper('wishlist')->getProductCollection()
            ->addFieldToFilter('sku', $item->getSku());
    
        if($_productCollection->count()) {
            return true;
        }
        return false;
    }
    

    This checks to see whether or not a product has been added into the current user's Wishlist. I called it my template file like this:

    if ($this->helper('wishlist')->isInWishlist($_product)) :
    

提交回复
热议问题