Get category (category custom fields) of parent product from feed

Hi Guys,

I have a situation,

On feed generation, I need to find the category custom field of parent product.
So I tried something like this

{% if product.parent %}
    {% set parentCategories = product.parent.categories %}
{% else %}
    {% set productCategories = product.categories %}
{% endif %}
{% for category in productCategories %}
    {{ category.customFields.xxxxxx }}
{% endfor %}

And I got this error message

It is not possible to read the parent association directly. Please read the parents via a separate call over the repository

I believe this is not possible in Shopware directly and we needed an extra query.

So how can we handle this?

I thought about update product Export criteria using some event, create a twig filter, update database directly. What may be the best solution?

Or is there any direct solutions available?

Please share your opinions.
Thank you