Effective Frenkel Hamiltonian for optical nonlinearities in semiconductors: Application to magnetoexcitons