public function login(array $user, array $cart)
    {
        $result = array();
        $this->hook->attach('cart.login.before', $user, $cart, $result, $this);

        if (!empty($result)) {
            return (array) $result;
        }

        if (!$this->config->get('cart_login_merge', 0)) {
            $this->cart->delete(array('user_id' => $user['user_id']));
        }

        if (!empty($cart['items'])) {
            foreach ($cart['items'] as $item) {
                $this->cart->update($item['cart_id'], array('user_id' => $user['user_id']));
            }
        }

        $this->cart->deleteCookie();
        $result = $this->getResultLogin($user);

        $this->hook->attach('cart.login.after', $user, $cart, $result, $this);
        return (array) $result;
    }