Skip to content

Developer Notes

This section provides technical insights for developers working with the Qoliber_ProductLabels module, including database structure, plugins, and event observers.


Database Tables

The module introduces two core tables to manage labels and their associations:

1. qoliber_productlabels_label

Stores the configuration and metadata of each product label.

Column Type Description
label_id int Primary Key (Auto Increment)
name varchar Label name
status tinyint Status (active/inactive)
active_from datetime Activation start date
active_to datetime Activation end date
priority int Display priority
type int Label type
qty_trigger varchar Quantity trigger rule
stock_trigger int Stock trigger rule
conditions_serialized text Serialized display conditions
label_serialized text Serialized label data

2. qoliber_productlabels_label_to_entity

Index table mapping labels to products and stores for optimized frontend rendering.

Column Type Description
label_id int Linked Label ID
product_id int Linked Product ID
store_id smallint Store View ID
  • Constraints: Unique index on (label_id, product_id, store_id)
  • Foreign Keys:

    • References qoliber_productlabels_label
    • References catalog_product_entity
    • References store
  • Indexes: Optimized for product_id and store_id lookups.


Plugins (Interceptors)

The module uses several frontend plugins to inject product labels into product images and galleries without affecting core behavior.

Target Class Plugin Name Plugin Class
Magento\Catalog\Block\Product\Image qoliber_label_renderer_plp Qoliber\ProductLabels\Plugin\Block\CatalogProductImage\ImagePlugin
Magento\Catalog\Block\Product\View\Gallery qoliber_label_renderer_pdp Qoliber\ProductLabels\Plugin\Block\CatalogProductImage\GalleryPlugin
Magento\Catalog\Block\Product\ImageFactory qoliber_add_model_to_image_rendered Qoliber\ProductLabels\Plugin\Block\CatalogProductImage\ImageFactoryPlugin

These plugins handle label rendering on:

  • PLP (Product Listing Page)
  • PDP (Product Detail Page)

Event Observers

The module listens to Magento events to efficiently fetch product data needed for label assignment.

Event Name Observer Class Purpose
catalog_block_product_list_collection Qoliber\ProductLabels\Observer\ListCollectionAfterLoad Fetch product IDs after collection load

This observer ensures that product IDs are captured during collection loading, allowing the module to apply labels efficiently with minimal performance impact.


Summary

  • Performance-Oriented: All database operations and plugins are optimized for minimal overhead.
  • Non-Intrusive Integration: Uses Magento's plugin and observer systems to avoid core overrides.
  • Scalable Design: The index table ensures fast label retrieval even on large catalogs.

For customization or extension of this module, developers should familiarize themselves with these core components.