My bad, I should have given you more explanations.
As you said, the line:
$namekey = $oneExtraField->field_namekey;
Is not used (it was present in my first version of the code and I forgot to remove it), so you only need to add the code:
$fieldNamekey = str_replace('item_','',$oneExtraField->field_namekey);
if(isset($this->row->$fieldNamekey))
$itemData = $this->row->$fieldNamekey;
Right after:
$itemData = JRequest::getString('item_data_' . $fieldName, $this->element->$fieldName);
This way the code will check if there is a product field named as your item field but without the "item_" at the beginning.
If it is existing, so we replace the value of $itemData which is setting the custom field value by the product field value.
So no need to replace anything by "item_gl_code" in this code, and this can work for as many fields as you want.