# SEO - Rich Snippets

> Production-grade JSON-LD structured data — Product, Organization, BreadcrumbList, FAQ, MerchantReturnPolicy and 20+ more, Google-2025 compliant.

## General Information

Rich snippets are how your products earn the eye-catching results in Google: star ratings, prices, availability, FAQs, breadcrumb trails, returns policy. They're driven by JSON-LD structured data ([schema.org](https://schema.org)), and Google has been steadily raising the bar on what's required to appear in rich-result placements. Most Magento stores either ship with no structured data at all, or with auto-generated markup that misses the fields Google now requires (`applicableCountry`, `itemCondition`, valid product variants on configurables) and gets silently dropped from rich results.

The Qoliber SEO Rich Snippets extension is the most complete structured-data system available for Magento 2. It ships 27 pre-built snippet templates, an admin-editable template engine for everything else, and full Google 2025 Merchant Listings compliance — so your store actually shows up with stars, prices and availability in the search results.

## What Does This Extension Do?

- **27 pre-installed snippet templates** across five tiers — Product, Organization, WebSite, BreadcrumbList, LocalBusiness, MerchantReturnPolicy, AggregateOffer, Reviews, FAQs and more. All ship inactive; merchants opt in after review.
- **Admin snippet editor** at **Marketing → SEO → Rich Snippets** — CodeMirror JSON editor with syntax highlighting and live variable autocomplete.
- **Variable substitution** — drop `{{product.name}}`, `{{product.rating}}`, `{{store.country}}` into any template; the engine resolves them per page render.
- **Conditional directives** — `@djson if/else/unless/exists` for dynamic schema generation. Emit `priceValidUntil` only when a special-price end date is set; emit `itemCondition` only on refurbished products.
- **Rich variable system** — product price, rating, availability, reviews, image, description, SKU, attributes; MSI-aware stock variables (`product.stock.qty`, `product.stock.isInStock`, `product.stock.availability`); store config (country, locale, name); auto-generated breadcrumbs.
- **Nested snippets** — templates can include other snippets (Product includes Offer); circular-dependency detection prevents infinite loops.
- **Configurable / bundle / grouped support** — a configurable publishes its ProductGroup with an Offer per variant (or one Offer at its "As low as" price); a bundle publishes an Offer for its cheapest purchasable configuration; grouped products get no invented combined offer. No `AggregateOffer` for variants, as Google advises.
- **Google 2025 Merchant Listings compliance** — `MerchantReturnPolicy` now ships `applicableCountry` (auto-sourced from your Magento store-country config) and `itemCondition`, the two fields Google started silently requiring in 2025.
- **Compact + Pretty-Print output modes** — minified single-line JSON in production; pretty-printed for debugging.

## Why Is This a Game Changer?

- **Compliant out of the box.** Google's 2025 Merchant Listings update started dropping product rich results when `applicableCountry` was missing. We emit it automatically. Existing installs get the upgrade via a data patch — no admin action.
- **Edit, don't fork.** Every snippet is a template the marketing team can edit in admin. No more "ask a developer to change the JSON-LD" tickets.
- **Safe by default.** Snippets ship inactive. You review the rendered output (with the built-in Pretty-Print mode) before turning them on, so nothing false ever ends up in your structured data.
- **Performance-aware.** The variable provider engine skips unused providers per snippet — a measurable per-page reduction on category pages with heavy snippet templates.
- **Multi-store correct.** Cache keys include the `store_id`, so swapping templates per language doesn't poison the cache for other store views.

## How Does It Work?

For each request, the module:

1. Looks up the snippets active for the current page type (product / category / CMS / homepage).
2. Resolves the variables each template references — calling only the providers actually needed.
3. Renders the JSON-LD via the templating engine, with conditional directives evaluated per entity.
4. Emits one `<script type="application/ld+json">` block per active snippet in the page head.

### Example: Product snippet output

```json
{
  "@context": "https://schema.org",
  "@type": "Product",
  "name": "Blue Yoga Pants",
  "description": "Premium technical fabric, four-way stretch.",
  "sku": "MP01",
  "image": "https://mystore.com/media/catalog/product/cache/.../mp01-blue-yoga-pants.jpg",
  "offers": {
    "@type": "Offer",
    "price": "79.00",
    "priceCurrency": "EUR",
    "availability": "https://schema.org/InStock",
    "hasMerchantReturnPolicy": {
      "@type": "MerchantReturnPolicy",
      "applicableCountry": "FR",
      "returnPolicyCategory": "https://schema.org/MerchantReturnFiniteReturnWindow",
      "merchantReturnDays": 30,
      "itemCondition": "https://schema.org/NewCondition"
    }
  },
  "aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": 4.6,
    "reviewCount": 142
  }
}
```

### Configuration at a glance

Find global settings under **Stores → Configuration → Qoliber → SEO: Rich Snippets**, and the snippet management UI at **Marketing → SEO → Rich Snippets**. Verify with [Google's Rich Results Test](https://search.google.com/test/rich-results) before going live.

<Admonition type="info" title="Google Search Console">
After installing or activating snippets, run Google's Rich Results Test against representative URLs to confirm Google parses them correctly. Search Console reports any structured-data errors detected during normal crawling.
</Admonition>

## What's New in 2.3

- **Google 2025 Merchant Listings compliance** — default `MerchantReturnPolicy` snippet emits `applicableCountry` (auto-sourced from store country config) and `itemCondition`. Existing installs upgraded via data patch.
- **Inactive defaults on fresh installs** — every default snippet ships disabled until reviewed; no "false claims" in your structured data on day one.
- **Variable provider filtering** — render pipeline skips providers a snippet doesn't reference; measurable per-page TTFB win on heavy templates.
- **Multi-store cache fix** — `getCacheKeyInfo()` now includes `store_id`, eliminating cross-store cache poisoning.
- **Circular dependency validator** — wired to the snippet save controller; dependency loops are caught at edit time, not render time.
