O'Reilly, of Raheen Drive, Tallaght, pleaded guilty to robbery at Daybreak Supermarket, Athgarvan, Co Kildare, on March 19, 2008, producing a knife in the course of a dispute at B&Q, Belgard Business Park, Tallaght on May 12, 2006, and robbery of Mark Ellis Pharmacy, Springfield Shopping Centre, Tallaght on May 13, 2006.
Margaret O'Reilly told defence counsel, Paul Carroll, that her son began having difficulties with drugs in his teens.
She said O'Reilly's father, who died before the original sentence hearing in November, was a caddy working on the European golf circuit with Padraig Harrington among others.
She said O'Reilly spent some time working on the circuit until he had a car accident which put an end to his father's efforts to find him work. She said when he came back to Ireland he relapsed into drug use and they sent him to a private clinic.
Judge Katherine Delahunt said it was clearly an "aggravating factor" that some of the offences had been committed while O'Reilly was on bail.
She accepted that his pleas of guilty were in ease of his victims and that he had carried out the robberies to get money to feed his drug addiction.
Judge Delahunt noted that O'Reilly had made attempts to deal with his 10-year drug problem, which had proved unsuccessful and said it was clear that he still had a significant amount of work before he even started rehabilitation.
The last year of the sentence was suspended on condition that O'Reilly undergo drug treatment upon his release from prison and liaise with the probation service for a year.
Garda Paul Shaw told Remy Farrell, prosecuting, that at 8.15am on the morning of March 19 last O'Reilly entered Daybreak Supermarket in Athgarvan, showed a gun to staff and demanded money from the till. O'Reilly took €700 and drove off in the direction of Dublin. Gardai observed the car, which had been stolen earlier, in Saggart. O'Reilly collided with the front wing of the garda car and was arrested after a short chase.
Gardai received a report from staff at B&Q in May 2006 that they were holding a man who had been found hiding in the store at closing time. Staff had confronted the man who produced a knife and they restrained him until gardai arrived. Gardai found O'Reilly in the store on the ground with his ankles tied.
Garda Ciaran Loughrey told Mr Farrell that the following day O'Reilly approached the dispensary in Mark Ellis Pharmacy and threatened staff with a knife. He demanded Dalmaine and cash before running from the shop. A female customer recognised O'Reilly and identified him to gardai.
Gda Shaw agreed with defence counsel, Paul Carroll, that the staff in the Kildare store thought he was messing until they saw the gun. He agreed the gun was found to be a pellet gun when the car was searched