-
Notifications
You must be signed in to change notification settings - Fork 67
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
Fix solidus4 compatibility #172
Fix solidus4 compatibility #172
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @shahmayur001. Thank you so much for modernizing this codebase. It was very outdated!
I just left one requested change to modernize the search override.
An additional thought is that since the new solidus starter frontend functions by copying over all the controller and views into the app that is utilizing the gem,
I would recommend we find a solution to have the overrides you have created here also be copied be over to the app.
My rough idea is to leave them as decorators but instead convert them to templates that are copied over when running the install generator. In this way we can still test the functionality here via the spec generated app whilst handing the code over to the main application that uses this gem.
Let me know what you think!
@ikraamg Thanks for the feedback and the suggestion! I believe the starter frontend is developed differently, as you mentioned. It seems to be more of a template where files are copied into the main application. If we were to copy additional files, don’t you think it could lead to a lot of unnecessary clutter in the main application? I noticed that other extensions are also handling things in a similar way to what we’ve done with this current extension. Let me know your thoughts! |
If this is the case with how other extensions deal with the new starter frontend, then that is okay 👍
That is precisely what my vision was. For it to be an "in-your-face" installation so you can integrate the changes into your (assumably) already customized controllers/views from the starter 😄 |
Maybe in that case, we can introduce a new generator command or propose the question later on to users, giving them the option to include it in the main application. That way, it becomes a choice |
dcb4cdf
to
e40485a
Compare
@kennyadsl You were right about this change, it is affecting the PR as well |
11daf38
to
aac1289
Compare
aac1289
to
bb655e7
Compare
@kennyadsl I’ve fixed the issue. Feel free to review it. |
@ikraamg Can you review the changes? |
@fthobe Sure. The PR will still need a write-access reviewer before merging but my review can add to the confidence of that final review. |
@ikraamg so you are just a poser having us do your work 😂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
The comments are not related to functional blockers but general improvements to further modernize this codebase and also reduce the amount of decorators/overrides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This controller turns out to be mostly a duplicate as it was probably implemented before solidus_backend had it own stores controller/UI. It can pretty much be ripped out a long with its permission sets etc. The view looks slightly different but does not seem to be missing anything essential aside from perhaps the @payment_methods
and @shipping_methods
def index | ||
@searcher = build_searcher(params) | ||
@products = @searcher.retrieve_products | ||
@taxonomies = get_taxonomies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the only change to this is get_taxonomies
to store the @taxons
.
It would be more ideal to not override this file but instead override: https://github.com/solidusio/solidus_starter_frontend/blob/main/templates/app/controllers/concerns/taxonomies.rb
which is made available in the store controller (parent of this one): https://github.com/solidusio/solidus_starter_frontend/blob/652caa6355253c969248fb66f1703bfe9879e927/templates/app/controllers/store_controller.rb#L6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, there's an helper method called taxonomies
now, which should return the same thing. If we want to keep backward compatibility we can still set the instance variables in a before_action
. By the way, why are we overwriting this controller? It doesn't seem like it's doing anything around multi stores.
display_includes. | ||
with_prices(current_pricing_options). | ||
includes([:option_values, :images]) | ||
@taxonomies = get_taxonomies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As before, it would be more ideal to not override this file but instead override: https://github.com/solidusio/solidus_starter_frontend/blob/main/templates/app/controllers/concerns/taxonomies.rb
which is made available in the store controller (parent of this one) already: https://github.com/solidusio/solidus_starter_frontend/blob/652caa6355253c969248fb66f1703bfe9879e927/templates/app/controllers/store_controller.rb#L6
@taxonomies = get_taxonomies | ||
@product_properties = @product.product_properties.includes(:property) | ||
@taxon = Spree::Taxon.find(params[:taxon_id]) if params[:taxon_id] | ||
@similar_products = @product.similar_products.select { |product| product.stores.include?(current_store) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, it would be better to override the similar products
method in the product model. Making both changes would mean that this override is not needed AFAIK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, that's the place! @shahmayur001 what do you think about changing similar_products
instead?
module SolidusMultiDomain | ||
module TaxonsControllerDecorator | ||
def show | ||
@taxon = ::Spree::Taxon.find_by_store_id_and_permalink!(current_store.id, params[:id]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change can be implemented on the load_taxon
method to avoid overriding the show
method.
return unless @taxon | ||
@searcher = build_searcher(params.merge(taxon: @taxon.id)) | ||
@products = @searcher.retrieve_products | ||
@taxonomies = get_taxonomies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be solved in the same way as the previous comments regarding taxonomy loading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file can be removed as the get_taxons method was removed: solidusio/solidus@fc491a7
@taxonomies ||= if current_store.present? | ||
::Spree::Taxonomy.where(["store_id = ?", | ||
current_store.id]) | ||
else | ||
::Spree::Taxonomy | ||
end | ||
@taxonomies = @taxonomies.includes(root: :children) | ||
@taxonomies | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the method that is available in the new starter frontend through the taxon helper so not required here anymore.
hey @ikraamg We appreciate the work you put in the comments, but as far as I understood sometimes opinions here vary on what should be removed and what not. Is the goal here a major release or having the app restored to a working state? I am happy to dedicate mayur to do that, but I would like a defined outcome giving that we delegating our company ressources to open source beyond a scope that provides what we need. Are going for a major release here that will be maintained by somebody or making making cosmetics for the main repo? |
@fthobe I don't have anything against merging this as is since it contains everything to get this working again. I can perhaps find some time in the upcoming weeks to make the remaining improvements in a seperate PR. |
@ikraamg that would be absolutely great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree about all of the @ikraamg improvement proposals, but yes, most of them were already there before, and might be out of scope for this PR. Still, it would be great to leave the extension in a better place and remove some technical debt if anyone has will to do it.
def index | ||
@searcher = build_searcher(params) | ||
@products = @searcher.retrieve_products | ||
@taxonomies = get_taxonomies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, there's an helper method called taxonomies
now, which should return the same thing. If we want to keep backward compatibility we can still set the instance variables in a before_action
. By the way, why are we overwriting this controller? It doesn't seem like it's doing anything around multi stores.
def tree(root_taxon:, item_classes:, current_item_classes:, max_level:) | ||
return if max_level < 1 || root_taxon.children.empty? | ||
|
||
filtered_taxons = root_taxon.children.joins(:taxonomy).where("spree_taxonomies.store_id = ?", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the only change made in this class?
@taxonomies = get_taxonomies | ||
@product_properties = @product.product_properties.includes(:property) | ||
@taxon = Spree::Taxon.find(params[:taxon_id]) if params[:taxon_id] | ||
@similar_products = @product.similar_products.select { |product| product.stores.include?(current_store) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, that's the place! @shahmayur001 what do you think about changing similar_products
instead?
@kennyadsl we can do that in a second run by end of march. We are currently giving priority to a Running System. |
Summary
This pull request introduces structural changes and enhancements to support the integration of the Solidus starter frontend with multi-domain functionality. It includes updates to controllers, test suite scripts, and test cases to ensure seamless compatibility with the starter frontend.
Key Changes
Structural Changes to Support the Starter Frontend:
Spree
namespacing from controller decorators to align with the starter frontend controllers.Add Scripts to Run Test Suites:
dummy-app
required for running test suites.Fix Test Cases: