Important
You are browsing documentation for version 5.0 of OroCommerce, supported until January 2025. Read the documentation for version 6.0 (the latest LTS version) to get up-to-date information.
See our Release Process documentation for more information on the currently supported and upcoming releases.
Partial Indexes
To use a partial index for the entity field, add the following condition as an additional option to the index definition:
$table->addIndex(['is_featured'], 'idx_oro_product_featured', [], ['where' => '(is_featured = true)']);
Note
PostgreSQL supports partial indexes, however MySQL does not. For MySQL, the additional option causes the database schema diversion.
To eliminate the negative impact for the MySQL-based instances and automatically adjust their database schema, declare the following service:
oro_product.event_listener.orm.featured_index_listener:
class: Oro\Bundle\EntityBundle\EventListener\ORM\PartialIndexListener
public: false
arguments:
- 'oro_product'
- 'idx_oro_product_featured'
tags:
- { name: doctrine.event_listener, event: loadClassMetadata }
The service removes the options not supported in MySQL from the index definition.