hotchand/module-mpn

A Magento 2 extension that dynamically injects MPN (Manufacturer Part Number) meta tags into product detail pages.

Maintainers

Package info

github.com/Hotchand/Magento-2-MPN-Meta-Tag

Type:magento2-module

pkg:composer/hotchand/module-mpn

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-08-25 07:52 UTC

This package is auto-updated.

Last update: 2026-08-25 07:53:04 UTC


README

Magento 2.4+ License: MIT

A lightweight, robust, and clean Magento 2 extension that dynamically injects MPN (Manufacturer Part Number) meta tags into product detail pages (catalog_product_view). Designed specifically to enhance SEO, Google Shopping compatibility, and Social / Open Graph indexing.

โœจ Features

  • Dynamic Meta Tag Injection: Automatically outputs <meta property="product:mpn"> and/or <meta name="mpn"> tags on product detail pages.
  • Flexible Tag Formats: Choose between:
    • Open Graph Protocol: <meta property="product:mpn" content="YOUR_MPN" />
    • Standard HTML Meta: <meta name="mpn" content="YOUR_MPN" />
    • Both Formats: Renders both for maximum search engine and crawler compatibility.
  • Custom Attribute Mapping: Dynamically select any product attribute (e.g., mpn, sku, manufacturer_part_number) via system configuration.
  • Store-Scoped Configuration: Supports default, website, and store-view specific settings.
  • Secure & Standard-Compliant: Uses native Magento 2 Escaper services, head.additional container injection, and clean architecture without heavy plugins or core overrides.

๐Ÿ“ Repository Structure

app/code/Hotchand/Mpn/
โ”œโ”€โ”€ Block/
โ”‚   โ””โ”€โ”€ Mpn.php
โ”œโ”€โ”€ Model/
โ”‚   โ”œโ”€โ”€ Adminhtml/
โ”‚   โ”‚   โ””โ”€โ”€ Source/
โ”‚   โ”‚       โ”œโ”€โ”€ MetaTagName.php
โ”‚   โ”‚       โ””โ”€โ”€ ProductAttributes.php
โ”‚   โ””โ”€โ”€ Config.php
โ”œโ”€โ”€ etc/
โ”‚   โ”œโ”€โ”€ adminhtml/
โ”‚   โ”‚   โ””โ”€โ”€ system.xml
โ”‚   โ”œโ”€โ”€ acl.xml
โ”‚   โ”œโ”€โ”€ config.xml
โ”‚   โ””โ”€โ”€ module.xml
โ”œโ”€โ”€ registration.php
โ”œโ”€โ”€ view/
โ”‚   โ””โ”€โ”€ frontend/
โ”‚       โ”œโ”€โ”€ layout/
โ”‚       โ”‚   โ””โ”€โ”€ catalog_product_view.xml
โ”‚       โ””โ”€โ”€ templates/
โ”‚           โ””โ”€โ”€ mpn.phtml
โ””โ”€โ”€ README.md

๐Ÿ› ๏ธ Installation

Manual Installation (app/code)

  1. Create the directory structure inside your Magento 2 root folder:

    mkdir -p app/code/Hotchand/Mpn
  2. Copy/extract all module files into app/code/Hotchand/Mpn/.

  3. Enable the module and run setup commands:

    bin/magento module:enable Hotchand_Mpn
    bin/magento setup:upgrade
    bin/magento setup:di:compile
    bin/magento setup:static-content:deploy -f
    bin/magento cache:flush

โš™๏ธ Configuration

  1. Log in to your Magento Admin Panel.
  2. Navigate to Stores > Configuration > Hotchand Extensions > MPN Meta Tag Config.
  3. Configure your settings:
    • Enable Module: Set to Yes / No.
    • Product Attribute for MPN: Select the product attribute containing your MPN values (e.g., mpn, sku, etc.).
    • Meta Tag Format: Select Open Graph, Standard Meta, or Both.
  4. Click Save Config and flush Magento cache (bin/magento cache:flush).

๐Ÿงช How It Works

  1. On product page layout initialization (catalog_product_view), Magento includes the Hotchand\Mpn\Block\Mpn block inside the head.additional container.
  2. The block verifies whether the module is enabled and fetches the active product from Magento\Framework\Registry.
  3. It retrieves the configured MPN attribute value (handling text, numeric, and dropdown select label conversions).
  4. The output template (mpn.phtml) escapes the value safely using Magento\Framework\Escaper and outputs the XML meta elements into the HTML <head>.

๐Ÿ’ป Requirements

  • Magento Open Source / Adobe Commerce: 2.4.x
  • PHP Version: 7.4 | 8.1 | 8.2 | 8.3

๐Ÿ“„ License

This project is open-source and available under the MIT License.