mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-04 07:09:14 +00:00
Split products by local/remote distributor: apply to products, search results and taxon pages
This commit is contained in:
10
app/controllers/spree/products_controller_decorator.rb
Normal file
10
app/controllers/spree/products_controller_decorator.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'open_food_web/split_products_by_distributor'
|
||||
|
||||
Spree::ProductsController.class_eval do
|
||||
include Spree::DistributorsHelper
|
||||
include OpenFoodWeb::SplitProductsByDistributor
|
||||
|
||||
respond_override :index => { :html => { :success => lambda {
|
||||
@products, @products_local, @products_remote = split_products_by_distributor @products, current_distributor
|
||||
} } }
|
||||
end
|
||||
10
app/controllers/spree/taxons_controller_decorator.rb
Normal file
10
app/controllers/spree/taxons_controller_decorator.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'open_food_web/split_products_by_distributor'
|
||||
|
||||
Spree::TaxonsController.class_eval do
|
||||
include Spree::DistributorsHelper
|
||||
include OpenFoodWeb::SplitProductsByDistributor
|
||||
|
||||
respond_override :show => { :html => { :success => lambda {
|
||||
@products, @products_local, @products_remote = split_products_by_distributor @products, current_distributor
|
||||
} } }
|
||||
end
|
||||
@@ -1,4 +1,19 @@
|
||||
Deface::Override.new(:virtual_path => "spree/home/index",
|
||||
:replace => "[data-hook='homepage_products']",
|
||||
:partial => "spree/shared/products_by_distributor",
|
||||
:name => "products")
|
||||
:name => "products_home")
|
||||
|
||||
Deface::Override.new(:virtual_path => "spree/products/index",
|
||||
:replace => "[data-hook='homepage_products']",
|
||||
:partial => "spree/shared/products_by_distributor",
|
||||
:name => "products_products")
|
||||
|
||||
Deface::Override.new(:virtual_path => "spree/products/index",
|
||||
:replace => "[data-hook='search_results']",
|
||||
:partial => "spree/shared/products_by_distributor",
|
||||
:name => "products_search")
|
||||
|
||||
Deface::Override.new(:virtual_path => "spree/taxons/show",
|
||||
:replace => "[data-hook='taxon_products']",
|
||||
:partial => "spree/shared/products_by_distributor",
|
||||
:name => "products_taxon")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
- if @products
|
||||
#products= render 'spree/shared/products', :products => @products
|
||||
#products= render 'spree/shared/products', :products => @products, :taxon => @taxon
|
||||
- else
|
||||
#products-local= render 'spree/shared/products', :products => @products_local
|
||||
#products-remote= render 'spree/shared/products', :products => @products_remote
|
||||
#products-local= render 'spree/shared/products', :products => @products_local, :taxon => @taxon
|
||||
#products-remote= render 'spree/shared/products', :products => @products_remote, :taxon => @taxon
|
||||
|
||||
Reference in New Issue
Block a user