Did you change $row to $product in each place it was used? Because your for loop uses a different value than the one from the built-in sidebox.