vaersaagod / seomate

SEO, mate! It's important. That's why SEOMate provides the tools you need to craft all the meta tags, sitemaps and JSON-LD microdata you need - in one highly configurable, open and friendly package - with a super-light footprint.
MIT License
36 stars 8 forks source link

Is commerce supported? #10

Closed JustJarethB closed 5 years ago

JustJarethB commented 5 years ago

I tried to use the seomateMeta hook for product pages but it throws an error.

Argument 1 passed to craft\helpers\UrlHelper::isAbsoluteUrl() must be of the type string,
null given, 
called in .../vendor/vaersaagod/seomate/src/services/UrlsService.php on line 164

On further inspection I also notice the lack of SEO Preview mode on products. Could you advise?

aelvan commented 5 years ago

Hi,

SEOMate works out of the box with commerce. I'm not able to reproduce the error you're describing. But the line referenced is in prepAlternateUrlForSite which is used to get the alternate urls for the different site. There should probably be a check for it there, but it would be interesting to know why url is null. You have public url's for your products set up on the product types? Do all of your sites have url's?

JustJarethB commented 5 years ago

Hi! We have a multisite setup but one of the sites isn't being worked on yet, it's more of an empty shell. The store on the main site (which had the hook in the templates) has a URL for each product type set up, but the other site does not have URLs set up. I would expect them to be completely separate though, I don't know why the seomate plugin would need a url for a product on a different site?

aelvan commented 5 years ago

I've added a fix for the error you're seeing, turns out it would occur for any element that had url's in some sites, but not in others. It'll be in the next tagged release.

I would expect them to be completely separate though, I don't know why the seomate plugin would need a url for a product on a different site?

By default, seomate outputs alternate urls for elements that exists in several sites. You can turn this off using the outputAlternate config setting, see the documentation for a description on when to disable it.

We're looking into adding preview to commerce products..

mmikkel commented 5 years ago

This issue should be resolved in SEOMate v1.0.5 – which also adds the SEO Preview feature for Products.

kevadamson commented 5 years ago

Does anyone have an example of the sitemapConfig details for showing products in the sitemap?

mmikkel commented 5 years ago

@kevadamson To generate sitemaps for other Element types than Entries – such as Commerce Products – you'll need to declare the classname for that Element type using the elementType attribute:

'sitemapConfig' => [
    'elements' => [
        'products' => [
            'elementType' => \craft\commerce\elements\Product::class,
            'params' => ['changefreq' => 'daily', 'priority' => 0.5],
        ],
    ]
],

Note that in addition to elementType and params you can also add a criteria array containing any Element Query parameters you might want SEOMate to use when generating the sitemap (for products, could be something like 'criteria' => ['type' => 'shirts'] or whatever).