Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Simplify Footer Links.

Matthew Kennedya3a9e75e77f0
diff --git a/frontend/app/views/spree/shared/_footer.html.erb b/frontend/app/views/spree/shared/_footer.html.erb
index 71366a2f88..ccbf72df2c 100644
--- a/frontend/app/views/spree/shared/_footer.html.erb
+++ b/frontend/app/views/spree/shared/_footer.html.erb
@@ -56,13 +56,7 @@
<%= link_to parent.name, spree_localized_item_link(parent) %>
</div>
<% parent.children.each do |child| %>
- <% if child.code == 'category' && child.item_type == 'Container' %>
- <% if child.children.present? %>
- <% child.children.each do |category_link| %>
- <div class="pt-2"><%= link_to category_link.name, spree_localized_item_link(category_link) %></div>
- <% end %>
- <% end %>
- <% end %>
+ <div class="pt-2"><%= link_to child.name, spree_localized_item_link(child) %></div>
<% end %>
</div>
<% end %>
diff --git a/sample/db/samples/menu_items.rb b/sample/db/samples/menu_items.rb
index 6ba5147f34..005ef65b5e 100644
--- a/sample/db/samples/menu_items.rb
+++ b/sample/db/samples/menu_items.rb
@@ -5,9 +5,9 @@ Spree::Menu.all.each do |menu|
end
MENUS.each do |menu|
- ##############
- # Root Items #
- ##############
+ ################
+ # Translations #
+ ################
case menu.locale
when 'en'
root_name_a = 'Women'
@@ -110,6 +110,10 @@ MENUS.each do |menu|
promo_b_subtitle = 'Obtenga hasta un 30% de descuento'
end
+
+ ##############
+ # Root Items #
+ ##############
woman_taxon = Spree::Taxon.find_by!(permalink: 'women')
menu_root_women = Spree::MenuItem.where(
name: root_name_a,
@@ -143,37 +147,38 @@ MENUS.each do |menu|
menu_root_sw.linked_resource_id = sw_taxon.id
menu_root_sw.save!
- ##############
- # Categories #
- ##############
- menu_cat_women = Spree::MenuItem.where(
- name: catagories,
- item_type: 'Container',
- code: 'category',
- menu_id: menu,
- parent_id: menu_root_women
- ).first_or_create!
+ if menu.location == 'header'
+ ## Only For Header Menu
+ ##############
+ # Categories #
+ ##############
+ menu_cat_women = Spree::MenuItem.where(
+ name: catagories,
+ item_type: 'Container',
+ code: 'category',
+ menu_id: menu,
+ parent_id: menu_root_women
+ ).first_or_create!
- menu_cat_men = Spree::MenuItem.where(
- name: catagories,
- item_type: 'Container',
- code: 'category',
- menu_id: menu,
- parent_id: menu_root_men
- ).first_or_create!
+ menu_cat_men = Spree::MenuItem.where(
+ name: catagories,
+ item_type: 'Container',
+ code: 'category',
+ menu_id: menu,
+ parent_id: menu_root_men
+ ).first_or_create!
- menu_cat_sw = Spree::MenuItem.where(
- name: catagories,
- item_type: 'Container',
- code: 'category',
- menu_id: menu,
- parent_id: menu_root_sw
- ).first_or_create!
+ menu_cat_sw = Spree::MenuItem.where(
+ name: catagories,
+ item_type: 'Container',
+ code: 'category',
+ menu_id: menu,
+ parent_id: menu_root_sw
+ ).first_or_create!
- ##############
- # Promotions #
- ##############
- if menu.location == 'header'
+ ##############
+ # Promotions #
+ ##############
menu_promo_women = Spree::MenuItem.where(
name: 'Promos',
item_type: 'Container',
@@ -237,13 +242,20 @@ MENUS.each do |menu|
#################################
# Links For: WOMEN / CATAGORIES #
#################################
+
+ women_link_parent_id = if menu.location == 'header'
+ menu_cat_women
+ else
+ menu_root_women
+ end
+
women_skirts_t = Spree::Taxon.find_by!(permalink: 'women/skirts')
women_skirts = Spree::MenuItem.where(
name: skirts,
linked_resource_type: 'Spree::Taxon',
item_type: 'Link',
menu_id: menu,
- parent_id: menu_cat_women
+ parent_id: women_link_parent_id
).first_or_create!
women_skirts.linked_resource_id = women_skirts_t.id
women_skirts.save!
@@ -254,7 +266,7 @@ MENUS.each do |menu|
linked_resource_type: 'Spree::Taxon',
item_type: 'Link',
menu_id: menu,
- parent_id: menu_cat_women
+ parent_id: women_link_parent_id
).first_or_create!
women_dresses.linked_resource_id = women_dresses_t.id
women_dresses.save!
@@ -265,7 +277,7 @@ MENUS.each do |menu|
linked_resource_type: 'Spree::Taxon',
item_type: 'Link',
menu_id: menu,
- parent_id: menu_cat_women
+ parent_id: women_link_parent_id
).first_or_create!
women_s_b.linked_resource_id = women_s_b_t.id
women_s_b.save!
@@ -276,7 +288,7 @@ MENUS.each do |menu|
linked_resource_type: 'Spree::Taxon',
item_type: 'Link',
menu_id: menu,
- parent_id: menu_cat_women
+ parent_id: women_link_parent_id
).first_or_create!
women_sweaters.linked_resource_id = women_sweaters_t.id
women_sweaters.save!
@@ -287,7 +299,7 @@ MENUS.each do |menu|
linked_resource_type: 'Spree::Taxon',
item_type: 'Link',
menu_id: menu,
- parent_id: menu_cat_women
+ parent_id: women_link_parent_id
).first_or_create!
women_tops_tees.linked_resource_id = women_tops_tees_t.id
women_tops_tees.save!
@@ -298,7 +310,7 @@ MENUS.each do |menu|
linked_resource_type: 'Spree::Taxon',
item_type: 'Link',
menu_id: menu,
- parent_id: menu_cat_women
+ parent_id: women_link_parent_id
).first_or_create!
women_j_c.linked_resource_id = women_j_c_t.id
women_j_c.save!
@@ -306,13 +318,20 @@ MENUS.each do |menu|
###############################
# Links For: MEN / CATAGORIES #
###############################
+
+ men_link_parent_id = if menu.location == 'header'
+ menu_cat_men
+ else
+ menu_root_men
+ end
+
men_shirts_t = Spree::Taxon.find_by!(permalink: 'men/shirts')
men_shirts = Spree::MenuItem.where(
name: shirts,
linked_resource_type: 'Spree::Taxon',
item_type: 'Link',
menu_id: menu,
- parent_id: menu_cat_men
+ parent_id: men_link_parent_id
).first_or_create!
men_shirts.linked_resource_id = men_shirts_t.id
men_shirts.save!
@@ -323,7 +342,7 @@ MENUS.each do |menu|
linked_resource_type: 'Spree::Taxon',
item_type: 'Link',
menu_id: menu,
- parent_id: menu_cat_men
+ parent_id: men_link_parent_id
).first_or_create!
men_t_shirts.linked_resource_id = men_t_shirts_t.id
men_t_shirts.save!
@@ -334,7 +353,7 @@ MENUS.each do |menu|
linked_resource_type: 'Spree::Taxon',
item_type: 'Link',
menu_id: menu,
- parent_id: menu_cat_men
+ parent_id: men_link_parent_id
).first_or_create!
men_sweaters.linked_resource_id = men_sweaters_t.id
men_sweaters.save!
@@ -345,7 +364,7 @@ MENUS.each do |menu|
linked_resource_type: 'Spree::Taxon',
item_type: 'Link',
menu_id: menu,
- parent_id: menu_cat_men
+ parent_id: men_link_parent_id
).first_or_create!
men_j_c.linked_resource_id = men_j_c_t.id
men_j_c.save!
@@ -353,13 +372,20 @@ MENUS.each do |menu|
######################################
# Links For: SPORTSWARE / CATAGORIES #
######################################
+
+ sw_link_parent_id = if menu.location == 'header'
+ menu_cat_sw
+ else
+ menu_root_sw
+ end
+
sw_tops_t = Spree::Taxon.find_by!(permalink: 'sportswear/tops')
sw_tops = Spree::MenuItem.where(
name: tops,
linked_resource_type: 'Spree::Taxon',
item_type: 'Link',
menu_id: menu,
- parent_id: menu_cat_sw
+ parent_id: sw_link_parent_id
).first_or_create!
sw_tops.linked_resource_id = sw_tops_t.id
sw_tops.save!
@@ -370,7 +396,7 @@ MENUS.each do |menu|
linked_resource_type: 'Spree::Taxon',
item_type: 'Link',
menu_id: menu,
- parent_id: menu_cat_sw
+ parent_id: sw_link_parent_id
).first_or_create!
sw_sweatshirts.linked_resource_id = sw_sweatshirts_t.id
sw_sweatshirts.save!
@@ -381,7 +407,7 @@ MENUS.each do |menu|
linked_resource_type: 'Spree::Taxon',
item_type: 'Link',
menu_id: menu,
- parent_id: menu_cat_sw
+ parent_id: sw_link_parent_id
).first_or_create!
sw_pants.linked_resource_id = sw_pants_t.id
sw_pants.save!