Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom fields not hydrated (?) before publishing product.updated event #3275

Open
jezzzm opened this issue Dec 15, 2024 · 0 comments
Open

custom fields not hydrated (?) before publishing product.updated event #3275

jezzzm opened this issue Dec 15, 2024 · 0 comments

Comments

@jezzzm
Copy link
Contributor

jezzzm commented Dec 15, 2024

Is your feature request related to a problem? Please describe.
I realised I had a bug in my code - I was checking product custom fields before deciding to add that product to a job queue or not. what i missed was that the custom fields objects was just a whole bunch of nulls.

i'm not sure, but i believe the translatableSaver isn't hydrating (for want of a better word) the updatedProduct with its custom fields before publishing the update event.

const updatedProduct = await this.translatableSaver.update({
ctx,
input,
entityType: Product,
translationType: ProductTranslation,
beforeSave: async p => {
if (input.facetValueIds) {
const facetValuesInOtherChannels = product.facetValues.filter(fv =>
fv.channels.every(channel => !idsAreEqual(channel.id, ctx.channelId)),
);
p.facetValues = [
...facetValuesInOtherChannels,
...(await this.facetValueService.findByIds(ctx, input.facetValueIds)),
];
}
await this.assetService.updateFeaturedAsset(ctx, p, input);
await this.assetService.updateEntityAssets(ctx, p, input);
},
});
await this.customFieldRelationService.updateRelations(ctx, Product, input, updatedProduct);
await this.eventBus.publish(new ProductEvent(ctx, updatedProduct, 'updated', input));

Describe the solution you'd like
the translatableSaver to populate custom fields before returning the product entity.

Describe alternatives you've considered
i have worked around this by making another request to get the whole product by id (including custom fields), but it'd be great to not have to do that.

Additional context
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant