Skip to content

Plugins & Observers

Complete reference for all 47 plugin declarations and 24 observer classes in Magento_Catalog with sortOrder, security implications, and performance considerations.

47 Plugins 24 Observers 14 Events

Plugins Overview

Magento_Catalog defines 47 plugin declarations across 5 areas (global, adminhtml, frontend, webapi_rest, webapi_soap). Plugins intercept method calls to modify behavior without modifying core code.

Global Area (di.xml)

23 plugins for core functionality

Adminhtml Area

5 plugins for admin operations

Frontend/WebAPI

19 plugins for API and frontend

Plugin Execution Order

Plugins execute by sortOrder (lowest first). Before plugins run in ascending order, After plugins run in descending order. Around plugins wrap the original method.

Core Plugin Classes

catalogTopmenu

Intercepts Magento\Theme\Block\Html\Topmenu

  • Type: Magento\Catalog\Plugin\Block\Topmenu
  • Purpose: Adds category tree to navigation menu
  • Methods: beforeGetHtml(), afterGetIdentities()

catalogLog

Intercepts Magento\Customer\Model\ResourceModel\Visitor

  • Type: Magento\Catalog\Model\Plugin\Log
  • Purpose: Cleans product comparison items when visitor data is cleaned
  • Methods: afterClean()

set_page_layout_default_value

Intercepts Magento\Catalog\Model\Category\DataProvider

  • Type: Magento\Catalog\Model\Plugin\SetPageLayoutDefaultValue
  • Purpose: Sets default page layout for new categories
  • Methods: afterGetData()

showOutOfStockValueChanged

Intercepts Magento\Config\Model\Config

  • Type: Magento\Catalog\Model\Plugin\ShowOutOfStockConfig
  • Purpose: Triggers reindex when "Show Out of Stock" config changes
  • Methods: aroundSave()

attributeValidation

Intercepts EAV attribute backend validation

  • Type: Magento\Catalog\Plugin\Model\Attribute\Backend\AttributeValidation
  • Purpose: Adds catalog-specific attribute validation
  • Methods: aroundValidate()

copy_quote_files_to_order

Intercepts quote to order conversion

  • Type: Magento\Catalog\Model\Plugin\QuoteItemProductOption
  • Purpose: Copies custom option files from quote to order
  • Methods: aroundConvertItem()

Indexer Plugins

A significant portion of Catalog plugins handle indexer invalidation when related entities change.

Plugin Name Target Indexer Affected
invalidatePriceIndexerOnWebsite Store\Model\ResourceModel\Website catalog_product_price
categoryProductWebsiteAfterDelete Store\Model\ResourceModel\Website catalog_category_product
storeViewResourceAroundSave Store\Model\ResourceModel\Store catalog_category_flat
catalogProductFlatIndexerStore Store\Model\ResourceModel\Store catalog_product_flat
categoryStoreAroundSave Store\Model\ResourceModel\Store catalog_category_product
productAttributesStoreViewSave Store\Model\ResourceModel\Store catalog_product_attribute
invalidatePriceIndexerOnCustomerGroup Customer\Model\ResourceModel\Group catalog_product_price
invalidateEavIndexerOnAttributeSetSave Eav\Model\Entity\Attribute\Set catalog_product_attribute

Observers (24 Classes)

Magento_Catalog includes 24 observer classes that respond to system events. Located in Observer/ directory.

ImageResizeAfterProductSave

Event: catalog_product_save_commit_after

Queues image resize operations after product save to avoid blocking the save operation.

SetSpecialPriceStartDate

Event: catalog_product_save_before

Sets special price start date to today if special price is set but start date is empty.

CategoryDesignAuthorization

Event: catalog_category_prepare_save

Checks admin user permissions before allowing design attribute changes on categories.

InvalidateCacheOnCategoryDesignChange

Event: catalog_category_save_after

Invalidates full page cache when category design settings change.

SwitchPriceAttributeScopeOnConfigChange

Event: admin_system_config_changed_section_catalog

Updates price attribute scope when catalog price scope config changes.

SynchronizeWebsiteAttributesOnStoreChange

Event: store_save_after

Synchronizes website-scoped EAV attributes when store view changes.

FlushCategoryPagesCache

Event: catalog_category_*

Flushes FPC for category pages when category data changes.

CategoryProductIndexer

Event: catalog_category_save_after

Triggers category-product indexer reindex after category save.

Events Reference

Key events dispatched by Magento_Catalog defined in etc/events.xml.

Product Events

  • magento_catalog_api_data_productinterface_save_before
  • magento_catalog_api_data_productinterface_save_after
  • magento_catalog_api_data_productinterface_delete_before
  • magento_catalog_api_data_productinterface_delete_after
  • magento_catalog_api_data_productinterface_load_after
  • catalog_product_save_before
  • catalog_product_save_commit_after

Category Events

  • magento_catalog_api_data_categoryinterface_save_before
  • magento_catalog_api_data_categoryinterface_save_after
  • magento_catalog_api_data_categoryinterface_delete_before
  • magento_catalog_api_data_categoryinterface_delete_after
  • magento_catalog_api_data_categoryinterface_load_after
  • catalog_category_prepare_save

Configuration Events

  • admin_system_config_changed_section_catalog
  • store_save_after

Performance Considerations

Plugin Performance Tips

  • Avoid Around plugins when possible - They wrap the entire method and can significantly impact performance.
  • Use sortOrder wisely - Lower sortOrder runs first. Don't use 0 unless necessary.
  • Check if already processing - Prevent infinite loops with state flags.

Observer Performance Tips

  • Use commit_after events for heavy operations - Don't block the main save transaction.
  • Queue async operations - Use message queues for image processing, indexing.
  • Scope observers correctly - Use area-specific events.xml to avoid unnecessary execution.

Security Consideration

Plugins have full access to method arguments and return values. Malicious plugins can intercept sensitive data. Always audit third-party modules for suspicious plugins on security-critical classes like CustomerRepository, OrderRepository, or PaymentInterface.