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.

Add Seo Robots field to the Store in Admin Panel

piotrpankoe04e27115549
diff --git a/backend/app/views/spree/admin/stores/_form.html.erb b/backend/app/views/spree/admin/stores/_form.html.erb
index cdbd76afbd..febb96d485 100644
--- a/backend/app/views/spree/admin/stores/_form.html.erb
+++ b/backend/app/views/spree/admin/stores/_form.html.erb
@@ -69,6 +69,11 @@
<%= f.text_field :meta_keywords, class: 'form-control' %>
<%= f.error_message_on :meta_keywords %>
<% end %>
+ <%= f.field_container :seo_robots, class:['form-group'] do %>
+ <%= f.label :seo_robots, Spree.t(:seo_robots) %>
+ <%= f.text_field :seo_robots, class: 'form-control' %>
+ <%= f.error_message_on :seo_robots %>
+ <% end %>
</div>
</div>
diff --git a/backend/spec/features/admin/store_spec.rb b/backend/spec/features/admin/store_spec.rb
index 98a62477b6..8e8f0c9d9e 100644
--- a/backend/spec/features/admin/store_spec.rb
+++ b/backend/spec/features/admin/store_spec.rb
@@ -28,6 +28,13 @@ describe 'Stores', type: :feature, js: true do
expect(page).to have_field(id: 'store_contact_email')
end
+ it 'has seo fields' do
+ expect(page).to have_field(id: 'store_seo_title')
+ expect(page).to have_field(id: 'store_meta_description')
+ expect(page).to have_field(id: 'store_meta_keywords')
+ expect(page).to have_field(id: 'store_seo_robots')
+ end
+
it 'creates a new store' do
fill_in 'Name', with: 'Store name'
fill_in 'Code', with: 'example_store'
@@ -39,7 +46,7 @@ describe 'Stores', type: :feature, js: true do
expect(page).to have_content('successfully created!')
end
- it 'creates a new store with footer info' do
+ it 'creates a new store with footer and seo data' do
fill_in 'Name', with: 'Store name'
fill_in 'Code', with: 'example_store'
fill_in 'URL', with: 'store.example.com'
@@ -48,6 +55,10 @@ describe 'Stores', type: :feature, js: true do
fill_in 'Address', with: 'New store address 123, City 123'
fill_in 'Contact phone', with: '123123123'
fill_in 'Contact email', with: '[email protected]'
+ fill_in 'SEO Title', with: 'Spree Store meta title'
+ fill_in 'Meta Description', with: 'Spree Store meta description'
+ fill_in 'Meta Keywords', with: 'Spree, Store'
+ fill_in 'SEO Robots', with: 'noindex'
click_button 'Create'
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index 48788da6cf..5e3779927d 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -142,7 +142,8 @@ en:
url: Site URL
meta_description: Meta Description
meta_keywords: Meta Keywords
- seo_title: Seo Title
+ seo_robots: SEO Robots
+ seo_title: SEO Title
name: Site Name
mail_from_address: Mail From Address
spree/store_credit:
@@ -1514,10 +1515,11 @@ en:
select_a_store_credit_reason: Select a reason for the store credit
select_stock: Select stock
selected_quantity_not_available: ! 'selected of %{item} is not available.'
- seo: SEO
send_copy_of_all_mails_to: Send Copy of All Mails To
send_mails_as: Send Mails As
- seo_title: SEO title
+ seo: SEO
+ seo_robots: SEO Robots
+ seo_title: SEO Title
server: Server
server_error: The server returned an error
settings: Settings
diff --git a/core/lib/spree/permitted_attributes.rb b/core/lib/spree/permitted_attributes.rb
index 61b2fb87ae..28e5bb4e75 100644
--- a/core/lib/spree/permitted_attributes.rb
+++ b/core/lib/spree/permitted_attributes.rb
@@ -101,7 +101,7 @@ module Spree
:customer_support_email, :facebook, :twitter, :instagram,
:description, :address, :contact_email, :contact_phone,
:default_locale, :default_country_id, :supported_currencies,
- :new_order_notifications_email, :mailer_logo, :checkout_zone_id]
+ :new_order_notifications_email, :mailer_logo, :checkout_zone_id, :seo_robots]
@@store_credit_attributes = %i[amount currency category_id memo]