-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Document or deprecate use of HTTP_SPREE_STORE header #1971
Comments
e.g., perhaps this can be extracted into https://github.com/solidusio/solidus_multi_domain? |
@brchristian Hi there, which solidus version are you using? I think this is fixed with this commit. When |
@kennyadsl I’m using the latest gem release, which is I note that out of the box, the default 2.2.1 store makes six My hunch is that only a small fraction of the Solidus user base have more than one Store. My personal opinion is that six SQL calls per pageview is a lot of DB chatter to support what is (IMO) a somewhat niche use-case. What do you think about trying to move this functionality out into the |
@kennyadsl Also, the commit you referenced was reverted by 0abb4d0! |
@brchristian I think the last commit you posted is not reverting the one I linked but it is just removing the deprecation previously set. As far as I can see this is the code you are using: def store
if store_key
Spree::Store.current(store_key)
else
Spree::Store.default
end
end
private
def store_key
@request.headers['HTTP_SPREE_STORE'] || @request.env['SERVER_NAME']
end So if Anyway I'm going to do some more testing on a clean solidus app and see if I find those queries and they are coming from other places in the code. Will keep you posted! |
@kennyadsl Oh, I think you are right about the deprecation. Sorry and thanks for the correction! When I create a brand new blank Solidus app, What’s more, I think that there is some redundancy because Seems like we can clean this up, for sure! |
@brchristian I think that moving that code out of core (in solidus_multi_domain as you suggested) is the best way to go. I've just opened a PR (#1993) with initial steps for having it done. Let's see what others think about it and I'll proceed with the rest of the needed PRs. |
This class logic is extracted from Solidus core, which is going to be simplified a lot to avoid multiple queries at each request if solidus_multi_domain extension is not used (solidusio/solidus#1971).
Steps to fix this issue:
|
This class logic is extracted from Solidus core, which is going to be simplified a lot to avoid multiple queries at each request if solidus_multi_domain extension is not used (solidusio/solidus#1971).
This class logic is extracted from Solidus core, which is going to be simplified a lot to avoid multiple queries at each request if solidus_multi_domain extension is not used (solidusio/solidus#1971).
This commit avoids doing 2 extra queries for every request (solidusio#1971) even when solidus store is not using solidus_multi_domain extension. This logic has now been moved to the solidus_multi_domain extension since it is needed only when multiple stores are expected (solidusio-contrib/solidus_multi_domain#67).
I also would like to remove support for I've opened #2041 which is related to this. It supports selecting a store by domain name and falling back to default with a single query ⚡. |
I think this one can be closed as per #2041, right @kennyadsl? |
Yes, thanks @aitbw ! |
I have noticed three(!) SQL calls related to
Spree::Store
on every single pageview and wondered what was going on...it seems excessive.The culprit is this line from
current_store.rb
:It seems that (since this commit from two years ago), the default method of checking the current store is by looking at the
HTTP_SPREE_STORE
response header.However, looking far and wide I could find a total of zero documentation both in the Solidus codebase, and on the entire internet (!), about how to set or use the
HTTP_SPREE_STORE
header.My feeling here is that we need to either (a) deprecate, or (b) document the use of this.
The text was updated successfully, but these errors were encountered: