SEO Rich Snippets for Magento 2
Overview
The SEO Rich Snippets extension for Magento 2 provides a powerful and flexible system for adding Schema.org structured data (JSON-LD) to your store pages. This helps search engines better understand your content and display rich results in search listings.
Key Features
Dynamic Variable System
- Automatic variable resolution - Access product data, store configuration, and custom attributes using a simple
{{variable.name}}syntax - Nested data access - Navigate through complex data structures with dot notation (e.g.,
{{product.manufacturer}}) - Type-safe resolvers - Dedicated resolvers for products, configurations, stores, and more
- Extensible - Create custom variable providers for your specific needs
DJson Template Engine
- Conditional rendering - Show/hide sections based on data availability using
@djson if condition - Loop support - Iterate through collections with
@djson for collection as item - Clean syntax - Write readable JSON templates without complex PHP logic
- Powerful - Handles complex nested structures and transformations
Snippet Management
- Admin UI - Full CRUD interface for managing rich snippets
- Snippet nesting - Reference and embed snippets within other snippets using
{{snippet.identifier}} - Circular dependency protection - Prevents infinite loops with 5-level nesting limit
- Page targeting - Control where snippets appear using page types, CMS pages, URL patterns, or custom handles
- Store views - Different snippets per store view
Pre-installed Snippets
The extension comes with ready-to-use snippets for common eCommerce scenarios:
Tier 1: Core Ecommerce - Product with offers, reviews, and ratings - Organization with contact information - WebSite with search functionality - BreadcrumbList navigation
Tier 2: Enhanced Features - FAQPage for customer service - ItemList for category pages - ProductGroup for configurable products
Tier 3: Business Information - Store with opening hours - LocalBusiness for physical locations - AboutPage and ContactPage
All snippets are fully customizable and can be enabled/disabled individually.
Product Features
- Aggregate ratings - Automatically converts Magento's 0-100 scale to Google's 1-5 scale
- Product reviews - Displays individual customer reviews with author, text, and date
- Pricing and availability - Shows current price, currency, and stock status
- Shipping details - Includes shipping rates and delivery times
- Return policy - Merchant return window and conditions
- Product images - Gallery support with multiple images
- Brand information - Manufacturer/brand data
Developer Features
- Variable extractors - Automatic variable discovery from templates
- Value resolvers - Prefix-based resolution system (product., config., store.*)
- Collection support - Iterate through product reviews, breadcrumbs, product listings
- Extensibility points - Add custom variable providers and value resolvers via di.xml
- Debug mode - View rendered JSON in pretty-print or minified format
- Logging - Detailed debug logging for troubleshooting
How It Works
1. Template Expansion
When a page loads, the system:
1. Finds all active snippets matching the current page
2. Expands nested snippet references (e.g., {{snippet.offer}} → actual offer JSON)
3. Creates a final template with all snippets merged
2. Variable Resolution
The system then:
1. Extracts all variables from the template (e.g., {{product.name}}, {{config.store.name}})
2. Resolves each variable using registered value resolvers
3. Builds a context array with all resolved data
3. DJson Processing
Finally:
1. Processes @djson if conditionals (show/hide sections)
2. Processes @djson for loops (iterate collections)
3. Replaces all variables with actual values
4. Outputs valid JSON-LD script tags
Example: Product Snippet
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "{{product.name}}",
"sku": "{{product.sku}}",
"image": "{{product.image}}",
"offers": "{{snippet.offer}}",
"@djson if product.reviewCount": {
"aggregateRating": "{{snippet.aggregate-rating}}",
"review": {
"@djson for productReviews as review": {
"@type": "Review",
"author": {
"@type": "Person",
"name": "{{review.nickname}}"
},
"reviewBody": "{{review.detail}}",
"datePublished": "{{review.createdAt}}"
}
}
}
}
This template: - Uses variables to get product data - Embeds the offer snippet - Conditionally shows reviews only if they exist - Loops through all product reviews
Benefits
For SEO
- Rich search results - Products appear with images, prices, ratings in Google
- Better CTR - Eye-catching search results increase click-through rates
- Voice search - Structured data helps voice assistants understand your content
- Knowledge graph - Your organization appears in Google's knowledge panel
For Developers
- No code templates - Marketers can edit snippets without touching PHP
- Type safety - Variable resolvers prevent runtime errors
- Maintainable - Clear separation of data and presentation
- Testable - Unit tests for snippet expansion and variable resolution
For Business
- Competitive advantage - Stand out in search results
- Trust signals - Display reviews and ratings prominently
- Local SEO - LocalBusiness schema helps with local search
- Reduced development time - Pre-built snippets for common scenarios
Quick Start
- Install the extension - See Installation Guide
- Configure settings - Enable the module and set debug mode - Configuration
- Review default snippets - Check Content → SEO Rich Snippets → Snippets
- Configure Magento settings - Set store information, contact details
- Test with Google - Use Rich Results Test
Documentation
- Installation - How to install the extension
- Configuration - Admin panel configuration
- Variables Reference - All available variables
- DJson Syntax - Template syntax and examples
- Default Snippets - Pre-installed snippets guide
- Advanced Topics - Custom providers, nesting, debugging
- Roadmap - Upcoming features
Support
For issues, feature requests, or questions: - Visit https://www.qoliber.com/ - Check the documentation - Review the code examples