Mmmh maybe check that `getValue($code)` does not return null?
Or even better, create a `getValueOption($code)` method inside Product which does that.