Q:

Novel about a boy going to pyramids to find treasure but found it in his own country

I didn't remember the exact details but it involved a shepherd who had a dream about a treasure.  He went to a fortune teller who tells him the treasure is in Egypt.  
He meets with a king who tells him about life.  He went to Egypt but loses all his money and ends up to working in a shop where he gathers money and once again sets for the pyramids.  

A:

This is The Alchemist by Paulo Coelho.  Wikipedia synopsis:

The Alchemist follows the journey of an Andalusian shepherd boy named Santiago.  Believing a recurring dream to be prophetic, he asks a Romani fortune-teller in a nearby town about its meaning.  The woman interprets the dream as a prophecy telling the boy that he will discover a treasure at the Egyptian pyramids. 
Early into his journey, he meets an old king named Melchizedek or the king of Salem, who tells him to sell his sheep so as to travel to Egypt and introduces the idea of a Personal Legend.  Your Personal Legend "is what you have always wanted to accomplish.  Everyone, when they are young, knows what their Personal Legend is."  He adds that "when you want something, all the universe conspires in helping you to achieve it."  This is the core theme of the book. 
Along the way, the boy meets an Englishman who has come in search of an Alchemist and continues his travels with him.  When they reach an oasis, Santiago meets and falls in love with an Arabian girl named Fatima, whom he asks to marry him.  She promises to do so only after he completes his journey.  He is frustrated by this, but later learns that true love will not stop nor must one sacrifice to it one's personal destiny, since to do so robs it of truth. 
The boy then encounters a wise alchemist who also teaches him to realize his true self.  Finally they risk a journey through the territory of warring tribes, where the boy is forced to demonstrate his oneness with "The Soul of the World" by turning himself into a simoom before he is allowed to proceed.  When he begins digging within sight of the pyramids, he is robbed but learns accidentally from the leader of the thieves that the treasure he seeks was all the time in the ruined church where he had his original dream.