/** * @param Buyable|BuyableModel $item * @return bool */ public function addBuyable($item) { if (!$this->ID) { $this->write(); } if ($this->hasBuyable($item)) { return false; } $myItem = new WishListItem(); $myItem->setBuyable($item); $myItem->WishListID = $this->ID; $myItem->write(); return true; }
/** * IF this item is an any of the current member's wishlists, * returns the wishlist item records. * * @return DataList */ public function WishListItems() { $listWhere = sprintf('"WishList"."ID" = "WishListItem"."WishListID" AND "WishList"."OwnerID" = \'%d\'', Member::currentUserID()); return WishListItem::get()->innerJoin('WishList', $listWhere)->filter(array('BuyableID' => $this->getOwner()->ID, 'BuyableClassName' => $this->getOwner()->ClassName)); }