dachcom-digital/pimcore-seo

Meta Data not attached

jeykodev opened this issue ยท 5 comments

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no

At first: thanks for your amazing bundles, it realy simplyfies our daily work! ๐Ÿ˜Š

My problem:

Just like in the offical pimcore demo I've build the following site structure in pimcores document tree:

image

The root document (ID 1) ist our start page and localized pages are created under its dedicated language path. Like in the demo we created a link from the root of our main language de to the root document /.

After setting up the bundle, everything works as expected but on the document root no meta data will be attached by the bundle. The reason for that is the AutoMetaDataAttachListener.php. The request is validated here so that the meta data will only be attached on certain conditions.

The attachment fails here:

if ($event->isMasterRequest() === false) {
return;
}

I think this is because the redirect from the language root to the document root.

Can you please confirm that this is the expected behaviour? How can we set the meta data in this cases? Thank you.

@Homer0815: I think I need more background here. Which document exactly does not have any attached data in your setup?

@Homer0815 Can't reproduce it. I just added the same setup with some SEO data on "Start" (Root) which just works fine. Of course, there will be a redirect first from /de to / and at this time, there is no available document.

@solverat Thanks for your answer. I still can reproduce the issue and digged a little bit deeper into the problem

@Homer0815: Which document exactly does not have any attached data in your setup?

The Problem is that no meta data will be attached on the document with the DocumentID=1, every other document works and there is no problem with any redirects (sorry that was a little missleading)

The cause for that can be found here:

$document = $this->documentResolverService->getDocument($request);
if (!$document instanceof Page) {
return;
}

I don't know why, but the root document cant be resolved using the DocumentResolver and the $document will be nullhere. Maybe there is some correlation with some other modules in the project. I will try to reproduce it with a clean installation.

@solverat Sorry, I found the issue. I've had this action in my DefaultController.php.:

/**

  • Handling the welcome Action
  • @ Route("/")
  • @ Template("Pages/main-content.html.twig")
  • @ param Request $request
    */
    public function defaultAction(Request $request)
    {

}

Because of the @Route annotion the request was resolved in a different way than calling a document from the document tree. Therefore no document was attached to the request, so your AutoMetaDataAttachListener.php did not attach the meta data, because it had no document for reference.

Thank you anyway and keep up your great work. ๐Ÿ˜Š

Glad you figured it out! ๐Ÿ‘