hotchand / module-mpn
A Magento 2 extension that dynamically injects MPN (Manufacturer Part Number) meta tags into product detail pages.
Package info
github.com/Hotchand/Magento-2-MPN-Meta-Tag
Type:magento2-module
pkg:composer/hotchand/module-mpn
Requires
- php: ~7.4.0||~8.1.0||~8.2.0||~8.3.0
- magento/framework: *
- magento/module-catalog: *
This package is auto-updated.
Last update: 2026-08-25 07:53:04 UTC
README
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.
- Open Graph Protocol:
- 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.additionalcontainer 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)
-
Create the directory structure inside your Magento 2 root folder:
mkdir -p app/code/Hotchand/Mpn
-
Copy/extract all module files into
app/code/Hotchand/Mpn/. -
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
- Log in to your Magento Admin Panel.
- Navigate to Stores > Configuration > Hotchand Extensions > MPN Meta Tag Config.
- 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, orBoth.
- Enable Module: Set to
- Click Save Config and flush Magento cache (
bin/magento cache:flush).
๐งช How It Works
- On product page layout initialization (
catalog_product_view), Magento includes theHotchand\Mpn\Block\Mpnblock inside thehead.additionalcontainer. - The block verifies whether the module is enabled and fetches the active product from
Magento\Framework\Registry. - It retrieves the configured MPN attribute value (handling text, numeric, and dropdown select label conversions).
- The output template (
mpn.phtml) escapes the value safely usingMagento\Framework\Escaperand 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.