public static function getCurrentBasket()
    {
        $settings = SuperCMSSession::singleton();

        try {
            $user = SCmsLoginProvider::getLoggedInUser();
            try {
                $basket = Basket::findLast(new AndGroup(
                    [
                        new Equals('UserID', $user->UniqueIdentifier),
                        new Not(new Equals('Status', self::STATUS_COMPLETED))
                    ]
                ));
            } catch (RecordNotFoundException $ex) {
                $basket = new Basket();
                $basket->UserID = $user->UniqueIdentifier;
                $basket->save();
            }

            if ($settings->basketId != $basket->UniqueIdentifier) {
                self::joinAnonymousBasketItemsToUserBasket($basket);
                self::updateSession($basket);
            }
        } catch (NotLoggedInException $ex) {
            try {
                $basket = new Basket($settings->basketId);
            } catch (RecordNotFoundException $ex) {
                $basket = new Basket();
                $basket->save();
                self::updateSession($basket);
            }
        }

        return $basket;
    }