magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.47k stars 9.28k forks source link

Robots meta tag should be configurable on storeview level, right now it's only on website level #35453

Open hostep opened 2 years ago

hostep commented 2 years ago

Preconditions (*)

  1. Magento 2.3.7 or 2.4.4. or any recent version

Steps to reproduce (*)

  1. Use a clean Magento installation
  2. Setup at least 2 storeviews
  3. In the backoffice, go to Content > Design > Configuration
  4. Click on 'Edit' for one of the storeviews
  5. Click open the 'Search Engine Robots' section

Expected result (*)

  1. To be able to configure the 'Default Robots' setting on storeview level

Actual result (*)

  1. The 'Default Robots' setting is only configurable on website level

Discussion

We have a case where we want to add a storeview to a shop that is live, for the shop owner to setup some new content But we don't want for search engines to start indexing this storeview already. So we would like to see the 'Default Robots' setting configurable on storeview level. I'm almost 99% convinced that this was possible in earlier versions of Magento (2.0, 2.1, 2.2 maybe?), but now it's not longer possible. From some testing and setting the config value directly in the database, this works fine, but there is currently no way to set it using the backoffice of Magento on storeview level.

Possible solution

diff --git a/app/code/Magento/Theme/Model/Design/Config/DataProvider.php b/app/code/Magento/Theme/Model/Design/Config/DataProvider.php
index 4cc6e81c3b8..7e15da7eb04 100644
--- a/app/code/Magento/Theme/Model/Design/Config/DataProvider.php
+++ b/app/code/Magento/Theme/Model/Design/Config/DataProvider.php
@@ -163,6 +163,8 @@ class DataProvider extends AbstractDataProvider
      */
     private function getSearchEngineRobotsMetadata($scope, array $fields = [])
     {
+        unset($fields['default_robots']);
+
         if ($scope == \Magento\Store\Model\ScopeInterface::SCOPE_STORES) {
             $resetToDefaultsData = [
                 'arguments' => [
diff --git a/app/code/Magento/Theme/view/adminhtml/ui_component/design_config_form.xml b/app/code/Magento/Theme/view/adminhtml/ui_component/design_config_form.xml
index dfe11f3120c..7102d3eb94b 100644
--- a/app/code/Magento/Theme/view/adminhtml/ui_component/design_config_form.xml
+++ b/app/code/Magento/Theme/view/adminhtml/ui_component/design_config_form.xml
@@ -274,7 +274,6 @@
                     <dataType>text</dataType>
                     <label translate="true">Default Robots</label>
                     <dataScope>default_robots</dataScope>
-                    <scopeLabel>[WEBSITE]</scopeLabel>
                 </settings>
                 <formElements>
                     <select>

It's a bit ugly, but for some reason Magento developers decided that the entire Search Engine Robots section should only be configurable on website scope, this probably makes sense for the 'custom instructions of the robots.txt file' content, but it doesn't make sense for the 'Default Robots' config setting.


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

m2-assistant[bot] commented 2 years ago

Hi @hostep. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

hostep commented 2 years ago

Just took a look at a Magento 2.1.7 and 2.1.11 shop, in 2.1.7 it was still configurable on storeview level, in 2.1.11 it no longer is.

So this got changed (broken?) somewhere between Magento 2.1.7 and 2.1.11

m2-assistant[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Hotel commented 2 years ago

Hello @hostep,

Thanks for the report and collaboration!

We have verified the issue in Magento 2.4-develop branch and the issue is reproducible for us. Hence confirming the issue.

Please refer to the below screenshots:

In the Storeview the Search Engine Robots section is not editable

image

In the Website level, the option is editable:

image

Thanks

github-jira-sync-bot commented 2 years ago

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-3047 is successfully created for this GitHub issue.

m2-assistant[bot] commented 2 years ago

:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

Pranav-242 commented 2 years ago

@magento i'm working on it

Nuranto commented 8 months ago

Hi,

Thanks for reporting and fixing this. I think we should do the same for custom_instructions, should'nt we ?

hostep commented 8 months ago

It only makes sense to configure custom_instructions differently if you use different domain names and want a different /robots.txt "file" per domain name. But it looks like you can configure different base_url's on storeview level, so then yes, we should make it configurable on storeview level as well I guess 👍