Skip to content
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

Issue #2802, #1146: Fixing sitemap generation folder #9094

Merged
merged 10 commits into from Apr 19, 2017

Conversation

@JosephMaxwell
Copy link
Contributor

JosephMaxwell commented Apr 2, 2017

Description

Magento assumes for the above tickets that robots.txt and the sitemap paths are to be found in the root directory. To get the sitemap to be generated in the pub folder (per Magento's recommendation), you need to set the base directory to be at least pub/. This resolves the issue by adding new configuration to app/etc/env.php:

directories/
    document_root_is_pub (bool)

The default keeps backward compatibility: if the value is not specified, original functionality remains (use of the root directory). If you specify document_root_is_pub and set it to true, the sitemap is located in the correct directory.

Fixed Issues

This is a fix for:

  1. #2802
  2. #1146

Manual testing scenarios

Before:

  1. Ensure that apache / nginx has the document root set to use /pub.
  2. Create a sitemap.
  3. Click the generate link.
  4. Try to access it: you will get a 404 error.

After:

  1. Sitemap should be generated, and you will not get a 404 error.
@magento-cicd2

This comment has been minimized.

Copy link
Contributor

magento-cicd2 commented Apr 2, 2017

CLA assistant check
All committers have signed the CLA.

@okorshenko okorshenko changed the title 2802: Fixing sitemap generation folder Issue #2802, #1146: Fixing sitemap generation folder Apr 2, 2017
@@ -41,10 +42,13 @@ public function __construct(
\Magento\Framework\Filesystem $filesystem,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
\Magento\Config\Model\Config\Reader\Source\Deployed\DocumentRoot $documentRoot = null,

This comment has been minimized.

Copy link
@okorshenko

okorshenko Apr 2, 2017

Contributor

please, update doc block

This comment has been minimized.

Copy link
@rodrigowebjump
*/
class DocumentRoot
{
private $config;

This comment has been minimized.

Copy link
@okorshenko

okorshenko Apr 2, 2017

Contributor

add doc block here

This comment has been minimized.

Copy link
@rodrigowebjump
@@ -34,10 +41,13 @@ public function __construct(
\Magento\Backend\Block\Context $context,
\Magento\Sitemap\Model\SitemapFactory $sitemapFactory,
\Magento\Framework\Filesystem $filesystem,
\Magento\Config\Model\Config\Reader\Source\Deployed\DocumentRoot $documentRoot = null,

This comment has been minimized.

Copy link
@okorshenko

okorshenko Apr 2, 2017

Contributor

please, update doc block

This comment has been minimized.

Copy link
@rodrigowebjump
@okorshenko okorshenko self-assigned this Apr 2, 2017
@okorshenko okorshenko added this to the April 2017 milestone Apr 2, 2017
@JosephMaxwell

This comment has been minimized.

Copy link
Contributor Author

JosephMaxwell commented Apr 14, 2017

@okorshenko: we updated the PR per your comments.

@magento-team magento-team merged commit 3cc0e5a into magento:develop Apr 19, 2017
3 checks passed
3 checks passed
codacy/pr Good work! A positive pull request.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
licence/cla Contributor License Agreement is signed.
Details
magento-team pushed a commit that referenced this pull request Apr 19, 2017
magento-team pushed a commit that referenced this pull request Apr 19, 2017
magento-team pushed a commit that referenced this pull request Apr 19, 2017
magento-team pushed a commit that referenced this pull request Apr 19, 2017
@magento-team

This comment has been minimized.

Copy link
Contributor

magento-team commented Apr 19, 2017

@JosephMaxwell thank you for your contribution. Your Pull Request has been successfully merged

@skovalenk

This comment has been minimized.

Copy link
Contributor

skovalenk commented Apr 28, 2017

@magento/community-gatekeepers @JosephMaxwell how other developers should learn about this configuration in env.php
ENV.PHP is file that should be generated, so by this logic there should be command which allows to switch root folder.
Or PR to documentation with this feature should be added.

@okorshenko

This comment has been minimized.

Copy link
Contributor

okorshenko commented May 16, 2017

Hi @sereban
We are working on documentation for this functionality.
Thank you

@avoelkl

This comment has been minimized.

Copy link
Contributor

avoelkl commented Nov 17, 2017

Hi @JosephMaxwell,
I just came across this PR because I was wondering if there was already a fix for the sitemap.xml issue - and there is! Thank you :)

I added the following to my env.php:

    'directories' =>
        array(
            'document_root_is_pub' => true
        ),

After clicking "Generate" the URL still contains /pub/ but the sitemap works with and without /pub:

  • /pub/sitemap/cz/cs/sitemap.xml
  • /sitemap/cz/cs/sitemap.xml

Is this the expected result?

@avstudnitz

This comment has been minimized.

Copy link
Contributor

avstudnitz commented Mar 20, 2018

@okorshenko What about said documentation? I can't find it...

@webspeaks

This comment has been minimized.

Copy link

webspeaks commented Aug 30, 2018

@okorshenko Any documentation available? This issue still exists in 2.2.5.

@jalogut

This comment has been minimized.

Copy link
Contributor

jalogut commented Sep 13, 2018

It would be great to find documentation about that in the dev docs. I only found that:

Is the 'document_root_is_pub' => true needed for something else too?

@OvalMedia

This comment has been minimized.

Copy link

OvalMedia commented Nov 19, 2019

2.2.9 and the issue persists. Nginx/Apache Docroot is set to /pub folder.
Sitemap entry in the robots.txt still looks like this:
"Sitemap: https://www.example.com/pub/sitemap.xml"

document_root_is_pub in env.php does not make any difference.

What am I missing here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

You can’t perform that action at this time.