Los plugins permiten modificar comportamiento sin sobrescribir clases del core.
Registrar plugin
Archivo etc/di.xml:
<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Catalog\Model\Product"> <plugin name="gdw_product_name_plugin" type="GDW\Hello\Plugin\ProductPlugin" sortOrder="10"/> </type></config>Clase plugin
<?phpnamespace GDW\Hello\Plugin;
use Magento\Catalog\Model\Product;
class ProductPlugin{ public function afterGetName(Product $subject, $result) { return $result . ' [GDW]'; }}Cuándo usar each tipo
before: cambia argumentos de entrada.after: modifica resultado final.around: controla ejecución completa (usar solo cuando sea necesario).
Conclusión
La mayoria de customizaciones se resuelve con after o before; around debe usarse con cuidado por impacto en performance y depuración.