This module provides GraphQL support for the Magento 2 Magmodules_AlternateHreflang
module (link), allowing you to retrieve hreflang
alternate URLs for products, categories, and CMS pages via GraphQL.
- GraphQL endpoint for retrieving alternate hreflang URLs.
- Per-entity resolvers for:
- Products
- Categories
- CMS Pages
- Uses Magento StoreView context for correct URL resolution.
Make sure the base module Magmodules_AlternateHreflang
is already installed.
-
Go to Magento® 2 root folder
-
Enter the following commands to install module:
composer require magmodules/m2-alternate-hreflang-graph-ql
-
Enter following commands to enable module:
php bin/magento module:enable Magmodules_AlternateHreflangGraphQl php bin/magento setup:upgrade php bin/magento cache:clean
-
If Magento® is running in production mode, deploy static content with the following command:
php bin/magento setup:static-content:deploy
{
products(filter: {sku: {eq: "example-sku"}}) {
items {
hreflang {
code
url
}
}
}
}
{
category(id: 3) {
hreflang {
code
url
}
}
}
{
cmsPage(identifier: "home") {
title
hreflang {
code
url
}
}
}
Ensure that the base module is enabled and that hreflang output is configured in the Magento Admin:
Stores > Configuration > Magmodules > Alternate Hreflang
CmsAlternateUrls
– GraphQL resolver for CMS pagesCategoryAlternateUrls
– GraphQL resolver for categoriesProductAlternateUrls
– GraphQL resolver for productsBaseAlternateResolver
– Shared helper logic for formatting response
Use tools like GraphiQL or Magento PWA Studio to test queries.
See COPYING.txt
. All rights reserved © Magmodules.eu.