Structured Data JSON-LD for Magento 2
Outputs one JSON-LD block per Magento 2 page with Product, Offer, BreadcrumbList, Organization, FAQPage and other schema.org types, and can remove Magento's own product markup. Configurable products, grouped products and dynamic price bundles get an AggregateOffer.
- Free
- Themes listed: Hyvä + Luma
composer require mage2kishan/module-structured-data
- Package requirementsRead the source documentation
- Developer profileView Upwork profile
- Themes listedHyvä + Luma
- PHP versions listed8.1, 8.2, 8.3, 8.4
- Installation questionsDiscuss your store setup
What it does for your store
The main features, as listed in the module documentation.
-
One JSON-LD block per page
Nodes from every provider are merged by @id and printed as one script tag.
-
Product and offers
Product with images, brand, gtin and mpn; Offer for simple products; AggregateOffer for configurable, grouped and dynamic price bundles.
-
Site and page nodes
Organization, WebSite with SearchAction, BreadcrumbList, ItemList on categories, WebPage or Article on CMS pages.
-
FAQPage from content
Builds FAQPage from question headings in product, category and CMS descriptions.
-
Merchant fields
Return policy and shipping details on each Offer, on by default. Set your real policy or switch them off.
-
Switch per schema
Turn each provider on or off, and optionally remove Magento JSON-LD and microdata from product blocks.
Installation
Example commands from the Magento root. Follow the package instructions and your staging and deployment process.
- 1Check the releaseMatch Magento, PHP, theme and dependency requirements.
- 2Install on stagingReview Composer changes and follow the package instructions.
- 3Configure and verifyUse the documented settings and test the affected features.
$ composer require mage2kishan/module-structured-data $ bin/magento setup:upgrade $ bin/magento setup:di:compile $ bin/magento setup:static-content:deploy -f $ bin/magento cache:clean
Listed requirements
These are the details supplied in this listing. Confirm the selected release supports your Magento edition, PHP and storefront.
| Magento versions listed | 2.4.6, 2.4.7, 2.4.8 |
|---|---|
| PHP versions listed | 8.1, 8.2, 8.3, 8.4 |
| Themes listed | Hyvä, Luma |
| Composer package | mage2kishan/module-structured-data |
Documentation
Product details and setup guidance. Check the package repository for release-specific instructions.
Schema.org JSON-LD built from your catalog
Structured Data adds schema.org JSON-LD to the Magento 2 storefront. Each provider builds nodes from catalog data and admin settings. Nodes with the same @id are merged, Offers without a price are dropped, and the result is printed as one script tag in head.additional. There is no JavaScript, so it works on Luma, Hyvä and other themes that render that container.
Product pages
- Product with name, SKU, URL, images, description, mpn, gtin, brand, audience, offers and aggregateRating.
- Offer with price, currency, availability, itemCondition, seller and priceValidUntil for simple, virtual and downloadable products.
- AggregateOffer with one child Offer per enabled child for configurable and grouped products, and an AggregateOffer with a price range for dynamic price bundles.
- Review nodes from approved product reviews, and AggregateRating from the review summary.
- VideoObject for external videos in the media gallery.
- Optional ProductGroup with hasVariant and variesBy for configurable products.
- Optional hasCertification, energy label, positive and negative notes, and custom JSON properties.
Other pages
- BreadcrumbList on product, category and CMS pages, with an optional category priority to choose the product path.
- ItemList of products on category pages only.
- WebPage or Article on CMS pages, and BlogPosting on Mageplaza, Magefan and Mirasvit blog posts.
- Organization with address, contact point, logo and sameAs profile links, and WebSite with a SearchAction to catalog search, on every page.
- FAQPage built from h2, h3 and h4 headings that end in a question mark, when a page has at least two of them.
Duplicate markup
With Remove Native Magento JSON-LD Markup on (the default), JSON-LD scripts and itemprop, itemscope and itemtype attributes are removed from the product info, breadcrumbs and final price blocks. The module's own script is kept. If Panth FAQ prints its own FAQ schema on a page, the extractor here stays quiet, and on Panth Testimonials pages the review provider does the same.
Settings
Stores > Configuration > Panth Extensions > Structured Data has a switch for every provider and groups for Organization details, social profile links, merchant return and shipping fields, product attribute codes and optional properties. Most providers are on by default; ProductGroup, pros and cons, energy label and certifications are off. Every field can be set per website and store view.
Merchant return and shipping details
The merchant return and shipping details are on by default, so every Offer carries them as soon as the module is enabled. The defaults are a 30 day return window with free returns by mail, a shipping rate of 0 and a transit time of 1 to 5 days. When the return or shipping country is left empty, the store country is used. Set these fields to your real return and shipping policy, or switch them off, before you rely on the output.
Checking the output
View the page source and look for the script tag marked data-panth-seo="jsonld", or paste the URL into Google's Rich Results Test. Search engines decide whether to show any enhanced result; markup alone does not guarantee one.
Requirements
- Magento Open Source or Adobe Commerce 2.4.4 to 2.4.8.
- PHP 8.1 to 8.4.
- mage2kishan/module-core, installed by Composer.
- Luma, Hyvä or another theme that renders head.additional.
Free and open source under the MIT License.
Developer notes
- Module
Panth_StructuredData, PHP namespacePanth\StructuredData. It loads afterPanth_Core,Magento_Catalog,Magento_CmsandMagento_Review. - Output comes from
Panth\StructuredData\Block\Head\StructuredData(layout namepanth_structured_data.head) inhead.additional, with the templatePanth_StructuredData::head/structured_data.phtmland the view modelPanth\StructuredData\ViewModel\StructuredData. - Providers implement
Panth\StructuredData\Api\StructuredDataProviderInterface(isApplicable(),getJsonLd(),getCode()). Add a new provider to theprovidersargument of bothModel\StructuredData\CompositeandModel\StructuredData\Aggregatorindi.xml. - A provider runs only when
panth_structured_data/structured_data/<code>is enabled, so a custom provider needs that value set.Helper\Config::isStructuredDataEnabled()holds the code to path mapping for the built-in providers. - Requesting the interface from the object manager returns
Composite, whosegetJsonLd()gives the full page graph as an array. - Nested arrays in nodes with the same
@idare merged recursively and later providers overwrite scalar values, except that a node typedSoftwareApplicationorProductGroupkeeps its@type. A failing provider is logged as a warning and skipped. - The JSON is encoded with
JSON_HEX_TAGandJSON_HEX_AMP, so <, > and & appear as\u003C,\u003Eand\u0026. - Plugins:
RemoveNativeMarkupPluginonMagento\Framework\View\Element\AbstractBlock,BreadcrumbPluginonMagento\Catalog\Helper\Data,CategoryFormPriorityPluginonMagento\Catalog\Model\Category\DataProvider, and on the storefrontRemoveProductPageMicrodataPluginandRemoveBodyMicrodataPlugin. The observerObserver\RegisterCmsPageruns oncms_page_render. - Data patches add the category attribute
breadcrumbs_priority(store scope) and the product attributespanth_is_software,panth_software_categoryandpanth_software_os(global scope). The module creates no database tables. - ACL resource
Panth_StructuredData::config.
| Module Category | SEO & Indexing |
|---|---|
| Best For | All Sizes |
FAQ
Will this slow down my storefront?
The head block is cacheable, so the JSON-LD is stored in the full page cache with the page. The providers run when a page is rendered without the cache.
Is it GDPR compliant?
The module prints data that is already shown on your storefront, such as product details, store details and approved reviews. Review nodes include the reviewer nickname from Magento reviews. Whether your store meets GDPR depends on your own setup and policies.
Can I disable individual schemas?
Yes. Product, Breadcrumb, Organization, WebSite, FAQ, Article, Review, VideoObject, Brand, Seller, Product List, ProductGroup, Pros/Cons, Energy Label, Certifications, Sale Event, merchant fields and Remove Native Markup each have their own switch.
Does it work with Hyvä?
Yes. The block has no JavaScript and is added to the head.additional container through layout XML, so the output is the same on Hyvä and Luma. Other themes work when they render head.additional.
Does it support multi-store / multi-language?
Yes. Every field can be set at default, website and store view scope, so store views can have different Organization details, profile links and switches. URLs use the current store base URL.
Can I customize the emitted JSON?
Yes. Use the Custom JSON-LD Properties field to merge a JSON object into the Product node, fill product attributes the providers read (such as manufacturer or gender), or add your own provider class to the providers list in di.xml.
Can I override a provider's output?
Yes. Replace one provider with your own class in the providers argument in your module's di.xml, or add a plugin on that provider's getJsonLd(). Do not set a preference on StructuredDataProviderInterface: it is bound to the composite that builds the whole graph.
Does it interact with Panth_AdvancedSEO, Panth_Faq, Panth_Testimonials?
Yes. It follows the panth_seo/general/enabled switch when Panth Advanced SEO is installed. The FAQ extractor stays quiet on Panth FAQ routes or when the Panth FAQ schema block has output. The review provider stays quiet on Panth Testimonials pages.
Is Panth_Core required?
Yes. mage2kishan/module-core is a required dependency and Composer installs it.
Does it emit itemprop / microdata?
No, only JSON-LD. With Remove Native Magento JSON-LD Markup on, itemprop, itemscope and itemtype attributes are removed from the product info, breadcrumbs and final price blocks.
What's the smallest Magento version supported?
Magento 2.4.4. The README lists 2.4.4 to 2.4.8.
Questions before you install?
Send me your composer.json and I will check for conflicts first. Free. Installation is +$45, custom work is quoted first.