vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.52k stars 977 forks source link

Multilingual collection query returning wrong ProductVariants #712

Closed chladog closed 1 month ago

chladog commented 3 years ago

Describe the bug When having multilingual setup, query collection with languageCode query set to other than default language will result in returning all ProductVariant items in the system (incl. disabled ones), not those of the collection. E.g. (localhost:3000/shop-api?languageCode=de)

Expected behavior Only products from the collection should be returned, and in that particular language.

Environment (please complete the following information):

michaelbromley commented 3 years ago

Hi, I cannot reproduce this issue on the current next branch, and as far as I know nothing changed on this part since v0.18.4. See video:

https://user-images.githubusercontent.com/6275952/108198752-512f2800-711c-11eb-8201-15e14305d865.mp4

s3m3n commented 3 years ago

@michaelbromley we found similar issue and it is related to dist release, when we build Core from source of Vendure there is no issue. It took us long hours to find out, must be related to some dependencies.

When we use dist package and make simple:

const variants = await this.productVariantService.getVariantsByCollectionId(ctx, id);

Where ctx has different language than default we receive the same product variants for every collection which is of course invalid behaviour. We load all collections at once for caching functionality. I believe it's the same issue as described by @chladog.

To test this you should use dist "@vendure/core" from the npm. Local build works fine on 0.18.4.

s3m3n commented 3 years ago

@michaelbromley new 0.18.5 build fixes problem available in 0.18.4 so this was dependencies problem as expected. Build of 0.18.4 from local sources was working fine.

coderjib commented 3 years ago

Hi all, I am having a hard time testing what's going on with search queries by collection slug or id (using languageCode=.. in the api endpoint), which are both returning wrong products in production, even after updating the system from v. 0.18.3 to 0.18.5. Also relates to #728 I opened some days ago. So here's what is happening to me now. Let's take for example the english version of my site: I search for products in the collection, no matter if by collection slug or id (I tried both), using ...?languageCode=en as an endpoint. The results include products that don't seem to exist in the admin panel. Searching for one of these product ids in the db I see that, in the search index table (postgres), I have 3 entries for this id, one is for Italian language, one for English (and these are the 2 "updated and correct" ones) and a third entry in English that is an old version of that product, that my customer has updated not so recently. This old product translation for some reason remained in the search index. I do have also a job table entry in failed state but it is not recent, and followed by many successful entries. Manually updating the search index doesn't solve the issue. In the product page (here an example) I get an error because I search the product by product slug and that product slug is the old one that shouldn't be there at all. The only solution I'm seeing right now is manually deleting all the products that result in an error. Please let me know if I can do anything to help addressing this issue and/or any effective workaround to make my production site work properly. Thanks

Izayda commented 2 years ago

Is it actual?

martijnvdbrug commented 1 month ago

Closing this, as it is reported as fixed in this comment above