Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $_product = ...; // some product object you already have
- $_productCollection = Mage::helper('wishlist')->getProductCollection()
- ->addFieldToFilter('sku', $_product->getSku());
- if($_productCollection->count() > 0) {
- // User already has item in wishlist.
- }
- public function isInWishlist($item)
- {
- $_productCollection = Mage::helper('wishlist')->getProductCollection()
- ->addFieldToFilter('sku', $item->getSku());
- if($_productCollection->count()) {
- return true;
- }
- return false;
- }
- if ($this->helper('wishlist')->isInWishlist($_product)) :
- function checkInWishilist($_product){
- Mage::getSingleton('customer/session')->isLoggedIn();
- $session = Mage::getSingleton('customer/session');
- $cidData = $session->isLoggedIn();
- $customer_id = $session->getId();
- if($customer_id){
- $wishlist = Mage::getModel('wishlist/item')->getCollection();
- $wishlist->getSelect()
- ->join(array('t2' => 'wishlist'),
- 'main_table.wishlist_id = t2.wishlist_id',
- array('wishlist_id','customer_id'))
- ->where('main_table.product_id = '.$_product->getId().' AND t2.customer_id='.$customer_id);
- $count = $wishlist->count();
- $wishlist = Mage::getModel('wishlist/item')->getCollection();
- }
- else{
- $count="0";
- }
- if($count) :
- return true;
- else:
- return false;
- endif;
- }
- <?php $wishlist = Mage::getModel('wishlist/item')->load($_product->getId(),'product_id');
- if($wishlist->getId())
- //product is added
- echo "Added! - Product is in the wishlist!";
- else
- //add product to wishlist
- echo "<a href='".$this->helper('wishlist')->getAddUrl($_product) ."'>Add This?</a>";
- ;?>
Add Comment
Please, Sign In to add comment