Question: is it by heart or by hard?
Answer: No, "learn by hard" is not a stock phrase in English, and it's not clear to native speakers what is meant. I believe most who hear this will assume that either they misheard or the speaker misspoke, and that the intended phrase was "learn by heart".