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

Missing products due to translations #166

Closed
kinduff opened this issue Oct 27, 2017 · 2 comments
Closed

Missing products due to translations #166

kinduff opened this issue Oct 27, 2017 · 2 comments

Comments

@kinduff
Copy link

kinduff commented Oct 27, 2017

Hello, I'm implementing this extension in a Spree 3-0-stable localized project.

I noticed that the product search was not returning any products (maked correctly), even though the query and scope are working correctly (search_can_be_part scope).

This is due to the extension spree_i18n version 3-0-stable because all products have a translation table (Spree::Product::Translation) and the query to search is not working the name field, so I made the following mod:

  scope :search_can_be_part, ->(query){ not_deleted.available.joins(:master, :translations)
    .where(Spree::Product::Translation.arel_table["name"].matches("%#{query}%").or(Spree::Variant.arel_table["sku"].matches("%#{query}%")))
    .where(can_be_part: true)
    .limit(30)
  }

I didn't made a PR because I'm not sure if this is the correct way to code it (works for me tho) or if it's even useful for other stores.

@sekretarot
Copy link

sekretarot commented Jul 19, 2018

I've also had this issue and fixed in a similar manner in a specific project.

This issue originates from I18n and is a common theme across multiple gems due to the separate translations tables. A lot of Spree functionality also seems to not work properly because of this. See this discussion on Ransack queries not working with I18n.

These issues are more of concern for spree_i18n gem which should provide some kind of infrastructure for clients to be able to query the model or translation without having to know if the app is localized or not.

There were some attempts to enable Ransack for this here but as far as I can see this is still an issue.

If I18n fixes its ransack queries then this might be rewritten with ransack but that would require adding it as a dependency.

@VygovskySergey
Copy link

Hello, this problem is missing in new versions of Spree, so i guess it was fixed.

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

3 participants