It is obligatory on any one intending to pray, to free his heart – according to his best ability- from those worldly things that occupy him and whatever is related to those things before entering the prayer.
When a matter becomes important to you, your heart automatically becomes engaged in it automatically. There is no cure to remove ones heart from such [ worldly] matters except by turning ones attention towards the importance of the prayer.
The level of turning one’s attention [towards prayer] varies according to the strength and weakness of one’s faith in the hereafter, and their level of disdain for worldly life.
Thus, whenever you see that your heart is not present in prayer, then know that the reason is due to weakness in faith [Iman] and so it is obligatory on you to strive towards reviving it.
May ALLAH strenghten Our Iman and accept Our Salat..Amen