MODRACXKENNETH D'SILVA

← Archive & Insights

Technical SEO & Structured Data Implementation for E-Commerce

The engineering blueprint for JSON-LD `@graph` schema design, Google Merchant Center rich snippets, variant product modeling, and PHP/Node.js automated schema generators.

By Kenneth D'SilvaReading Time: 45 min readCategory: SEO & Marketing

1. Structured Data as Machine Readable API Contracts

Search engine algorithms no longer rely solely on keyword matching. Modern search engines use Knowledge Graphs to understand entities, prices, stock levels, and brand relationships. Structured data injected via application/ld+json acts as a direct, machine-readable API contract with Googlebot.


2. Production PHP Magento 2 JSON-LD Generator Module

<?php
namespace Modracx\Seo\Block;

use Magento\Framework\View\Element\Template;
use Magento\Catalog\Model\Product;

class JsonLdBlock extends Template
{
    protected $_registry;

    public function __construct(
        Template\Context $context,
        \Magento\Framework\Registry $registry,
        array $data = []
    ) {
        $this->_registry = $registry;
        parent::__construct($context, $data);
    }

    public function getJsonLdSchema(): string
    {
        /** @var Product $product */
        $product = $this->_registry->registry('current_product');
        if (!$product) return '';

        $schema = [
            '@context' => 'https://schema.org',
            '@type' => 'Product',
            'name' => $product->getName(),
            'sku' => $product->getSku(),
            'description' => strip_tags($product->getDescription()),
            'offers' => [
                '@type' => 'Offer',
                'price' => number_format($product->getFinalPrice(), 2, '.', ''),
                'priceCurrency' => 'USD',
                'availability' => $product->isAvailable() ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock'
            ]
        ];

        return json_encode($schema, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
    }
}

3. Frequently Asked Questions (FAQ)

1. Why is the Schema.org @graph paradigm superior?

The `@graph` array establishes explicit relationships between entities in a single JSON block, preventing misparsing by search engine crawlers.

2. How should variant product schemas be modeled?

Use `ProductGroup` or `AggregateOffer` blocks with explicit GTINs, SKUs, and individual stock availability per variant.


Suggested & Related Reading

Explore related engineering guides from Kenneth D'Silva: