Back to PhocacartWishlist class

Method getWishListItemdDb

public
getWishListItemdDb
()

Method getWishListItemdDb - Source code

public function getWishListItemdDb()
{
    if ($this->user->id > 0) {
        $db = Factory::getDBO();
        $query = 'SELECT a.product_id, a.category_id, a.user_id' . ' FROM #__phocacart_wishlists AS a' . ' WHERE a.user_id = ' . (int) $this->user->id . ' ORDER BY a.id';
        $db->setQuery($query);
        $items = $db->loadAssocList();
        $itemsSorted = array();
        if (!empty($items)) {
            foreach ($items as $k => $v) {
                $itemsSorted[$v['product_id']]['product_id'] = $v['product_id'];
                $itemsSorted[$v['product_id']]['category_id'] = $v['category_id'];
                $itemsSorted[$v['product_id']]['user_id'] = $v['user_id'];
            }
            if (!empty($itemsSorted)) {
                return $itemsSorted;
            }
            return false;
        }
    }
    return false;
}