Magento 2 Interceptor Plugin Implementation
<?php
namespace Modracx\CustomCatalog\Plugin;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Api\Data\ProductInterface;
class ProductSavePlugin
{
public function beforeSave(
ProductRepositoryInterface $subject,
ProductInterface $product
) {
// Intercept product save to normalize custom attributes
if (!$product->getCustomAttribute('seo_slug')) {
$slug = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $product->getName())));
$product->setCustomAttribute('seo_slug', $slug);
}
return [$product];
}
}
Suggested & Related Reading
Explore related engineering guides from Kenneth D'Silva:
-
Comprehensive Security Hardening Checklist for Magento 2
Linux file permissions and environment security.
-
Performance Optimization for Magento & Shopify Stores
Redis cache backend and Varnish FPC rules.