You need to create a key which concatenates the id of the good with the pid of the outputRow:
<xsl:key name="elementsByPid" match="ns1:outputRow[@pid]" use="concat(ancestor::ns1:Good/@id, '|', @pid)" />
Then use key('elementsByPid', concat(ancestor::ns1:Good/@id, '|', @pid))
.