Hi,
What you can do is this:
- create a new joomla user group named "has bought product Y" (or something else) via the Joomla user groups manager
- edit the product Y, and in its "user group after purchase" setting, select the user group you just created
- edit the product X, and in its "access level" setting, select the user group you just created
That way, product X will only be accessible if the current user is logged in with a user account linked to the "has bought product Y" user group, and this user group will be added automatically to the user account when he purchases the product Y.