ethercreative / seo

SEO utilities including a unique field type, sitemap & redirect manager
MIT License
269 stars 96 forks source link

Sitemap Sections Issue #409

Closed zadro closed 2 years ago

zadro commented 2 years ago

Description

Sitemap.xml is working as expected. However, any of the sitemap section files, ie. "sitemap_sections_1_0.xml" is throwing an error:

Calling unknown method: craft\models\FieldLayout::getFields()

in /home/user/craft/vendor/ether/seo/src/services/SitemapService.php at line 316 – [yii\base\Component::call](http://www.yiiframework.com/doc-2.0/yii-base-component.html#call()-detail)()

        {
            $fieldLayout =
                $variables['section'] === 'categories' || $variables['section'] === 'productTypes'
                    ? $first->fieldLayout
                    : $first->type->fieldLayout;

            foreach ($fieldLayout->getFields() as $field)
                if (get_class($field) === SeoField::class)
                    $seoFieldHandle = $field->handle;
        }

        foreach ($elements->all() as $item)
        {

Steps to reproduce

  1. Enabled "dev" mode
  2. Navigated to any sitemap section file

Additional info

zadro commented 2 years ago

Per this update: https://github.com/nystudio107/craft-seomatic/releases/tag/4.0.0-beta.6

It looks like the fix is to change getFields() to getCustomFields()

Please merge and update.

moondawg69 commented 2 years ago

@zadro I too can confirm the above issue, be nice if it could become a quick fix :)

niektenhoopen commented 2 years ago

@zadro I have implemented your suggestion and it seems to work. I have created PR #410 for it

AnthonyLaSala commented 1 year ago

This also fixed my unrelated Calling unknown method: craft\models\FieldLayout::getFields() issue. Just commenting this so it is more searchable for people. This fix was not easy to find