You are browsing the documentation for version 4.2 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation 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 additional option to the index definition:

$table->addIndex(['is_featured'], 'idx_oro_product_featured', [], ['where' => '(is_featured = true)']);


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:

    class: Oro\Bundle\EntityBundle\EventListener\ORM\PartialIndexListener
    public: false
        - 'oro_product'
        - 'idx_oro_product_featured'
        - { name: doctrine.event_listener, event: loadClassMetadata }

The service removes the options that are not supported in MySQL from the index definition.