A Philadelphia police officer was shot and killed on Thursday after he happened to be in a video game store while it was being robbed and tried to stop the robbery, authorities said.

Officer Robert Wilson III was stopping to buy his son a video game to reward him for doing well in school, according to Charles H. Ramsey, the Philadelphia police commissioner.

“What parent probably hasn’t done that for a child in recognition of good work?” Ramsey told reporters on Friday morning. “He happens to be there at the time these two guys come in to commit a robbery.”

Wilson is the second police officer shot and killed this year by a suspect, and the second officer killed this way in as many days, according to groups that track police deaths.

Early Wednesday morning, an officer in Georgia was killed in what authorities described as an ambush after police responded to a report of shots fired in the area.

On Friday, police provided more details of what occurred inside and outside a GameStop in northern Philadelphia a day earlier, saying that Wilson was shot multiple times before he was killed.

Wilson “became engaged in a fierce and violent gun battle with both armed suspects,” Capt. James Clark said at a news conference about the shooting.

The two men involved were identified on Friday by police as Ramone Williams and Carlton Hipps, two brothers, one of whom gave a full confession, the Philadelphia Inquirer reported.

Ramsey said that Wilson moved away from the counter inside the store, trying to keep other people inside the store out of the path of the firefight that ensued.

“When you look at the actions of the officer, I think he redefined what a hero is all about,” Ramsey said at the news conference Friday.

Wilson was the first Philadelphia police officer killed in the line of duty since 2012, when Officer Moses Walker Jr. was shot during an attempted robbery, according to a memorial to fallen officers kept by the department.

“It’s a tremendous loss in so many ways,” Ramsey said Friday. “Our focus now is really trying to get the family through it, particularly his son. It’s just a tough time for everybody.”

Philadelphia Archbishop Charles J. Caput called Wilson’s death “senseless and devastating” in a statement Friday.

“I offer my prayerful condolences to his family, his fellow officers, and all those who mourn his loss,” he said.