Oro Documentation
Oro Documentation
  • USERS
  • DEVELOPERS
    • Backend Developer Guide
    • Frontend Developer Guide
    • Community Guide
  • CLOUD
  • BLOG
  • FORUM
  • Home >
  • Developer Documentation >
  • Backend Developer Guide >
  • Bundles Documentation >
  • OroProductBundle >
  • Product Variant Search
  • Backend Developer Guide
    • Setup
      • System Requirements
        • Performance Optimization
        • MySQL Optimization
      • Development Environment
        • Environment Setup for Community Edition
        • Environment Setup for Enterprise Edition
        • Web Server Configuration
        • Healthcheck and Data Monitoring
      • Demo Environment
        • VM VirtualBox
        • AWS Cloud Platform
        • Vagrant Provision
      • Installation
      • Installation in Sub-Folder
      • Loading Demo Data
      • Launch
      • Upgrade
      • Reinstall
      • Protect Cookies
    • Application Architecture
      • Technology Stack
        • Database
        • Search Index
          • ORM Search Engine
          • Elasticsearch
        • Message Queue
      • Application Structure
      • Application Framework
        • Architecture Principles of Oro Applications
      • Application Customization
      • Differences to Common Symfony Applications
      • Custom Oro Application
    • Bundles and Extensions
      • Create a Bundle
      • Extend an Existing Bundle
      • Install Extension from the Oro Marketplace
      • Add an Extension to Oro Marketplace
    • Entities
      • Create Entities
      • Extend Entities
      • Configure Entities
      • CRUD Operations
      • Data Grids
        • Pass Request Parameters to the Grid
      • Protect Entities Using ACLs
      • Entity Activities
      • Entity Attachments
      • Customize CRUD Pages
      • Customize Data Grid
    • Entities Data Management
      • Fixtures and Demo Data
      • Reports & Segments
      • Search Index
        • Configuration
        • Console Commands
        • Query Builder
        • Best Practices
        • Troubleshooting
      • Workflows
        • Introduction
        • Configuration Reference
        • Elements
        • Basic Configuration
        • Transition Forms
        • Translation Wizard
        • Configuration Example
      • Operations (Actions)
        • Glossary
        • Buttons
        • Action Groups
        • Configuration Reference
        • Actions and Conditions
        • Console Commands
      • Processes
      • Data Audit
    • Security
      • Introduction to Security in Oro Applications
      • Access Levels and Ownership (Example)
    • Translation and Localization
      • Translation
      • Localization
    • Integrations
      • Create an Integration
      • Import and Export Entities
      • Extend Entities to Support Bulk Import and Export
      • Accelerate Import
    • Dashboards
    • Navigation
    • Emails
    • Message Queue
      • Message Queue Jobs
      • Consumer
        • Resetting Container
      • Security Context
      • Logging, Error Handling and Debugging
        • Writing Logs to ELK Stack
      • Testing
      • RabbitMQ (Enterprise Edition Only)
        • Command Lines
        • Divide Queue to Separate Queues
        • Configure RabbitMQ for Production
        • Backup and Restore
        • Troubleshooting
      • Supervisord
    • Cron
    • WebSocket Notifications
      • Websocket Recipes
        • Use Maintenance Mode Notifications in Oro Applications
        • Use Content Outdated Notifications in Oro Applications
        • Create a Topic and a Handler for Publishing and Subscribing
        • Publish Messages to Existing Topics
        • Use Authentication and Authorization in WebSocket Connections
      • WebSocket Connection Configuration
    • Scopes
    • Feature Toggle
    • Logging
    • System Configuration
    • Configuration Reference
      • Annotations
        • @Acl
        • @AclAncestor
        • @Config
        • @ConfigField
        • @TitleTemplate
      • YAML
        • Access Control Lists
        • Assets
        • Dashboards
        • Datagrids
        • Entity Configuration
        • Navigation
        • Placeholders
        • Require.JS
        • Search Index
        • System Configuration
        • Workflows
    • Extending OroCRM
      • Add OroCommerce Capabilities to an OroCRM Application
    • Extending OroCommerce
      • Payment Methods
      • Shipping Methods
    • Akeneo Integration
    • Automated Tests
      • Functional Tests
      • Behat Tests
    • API Developer Guide
      • Using Web Services API
        • WSSE Authentication
        • Simple Search API
        • Advanced Search API
      • Actions
      • CLI Commands
      • Configuration Extensions
      • Configuration Extras
      • Configuration Reference
      • Documenting API Resources
      • Forms and Validators Configuration
      • Headers
      • Filters
      • How to
      • Processors
      • Configure Stateless Security Firewalls
      • Testing REST Api
      • Request Type
      • CORS Configuration
      • Entity Aliases
    • Bundles Documentation
      • OroActionBundle
      • OroActivityBundle
      • OroActivityListBundle
      • OroAddressBundle
      • OroApiBundle
      • OroAssetBundle
      • OroAttachmentBundle
        • OroAttachmentBundle Configuration
      • OroBatchBundle
      • OroCacheBundle
        • Cache in Oro Application
      • OroCalendarBundle
      • OroChartBundle
      • OroCommentBundle
      • OroConfigBundle
      • OroCronBundle
      • OroCurrencyBundle
      • OroDashboardBundle
      • OroDataAuditBundle
      • OroDataGridBundle
      • OroDistributionBundle
      • OroEmailBundle
      • OroEmbeddedFormBundle
      • OroEntityBundle
      • OroEntityConfigBundle
      • OroEntityExtendBundle
      • OroEntityMergeBundle
      • OroEntityPaginationBundle
      • OroEntitySerializedFieldsBundle
      • OroFeatureToggleBundle
      • OroFilterBundle
      • OroFormBundle
      • OroGaufretteBundle
      • OroGridFSConfigBundle
      • OroImapBundle
      • OroImportExportBundle
      • OroInstallerBundle
      • OroIntegrationBundle
      • OroLayoutBundle
        • Layout Cache
      • OroLocaleBundle
      • OroLoggerBundle
      • OroMessageQueueBundle
      • OroMigrationBundle
      • OroNavigationBundle
      • OroNoteBundle
      • OroNotificationBundle
      • OroOrganizationBundle
      • OroPlatformBundle
      • OroQueryDesignerBundle
      • OroRedisConfigBundle
      • OroReportBundle
      • OroRequireJSBundle
      • OroScopeBundle
      • OroSearchBundle
      • OroSecurityBundle
      • OroSegmentBundle
      • OroSidebarBundle
      • OroSyncBundle
      • OroTagBundle
      • OroTestFrameworkBundle
        • Additional Doctrine Events
      • OroThemeBundle
      • OroTranslationBundle
      • OroTwigInspector
      • OroUIBundle
        • Action Manager
        • Client Side Navigation
        • Content Providers
        • Dynamic Assets
        • Formatters
        • Scroll Data Customization
        • TWIG Placeholders
        • TWIG Filters
        • Widgets
        • ApiAccessor
        • BaseClass
        • HiddenInitializationView ⇐ BaseView
        • Layout Subtree View
        • LoadMoreCollection
        • Loading Mask View
        • MultiUseResourceManager ⇐ BaseClass
        • PersistentStorage
        • Highlight Text View
        • RouteModel
        • RoutingCollection
        • SearchApiAccessor
        • Viewport Manager
        • Error Handler
        • Input Widgets
        • Items Manager
        • Mediator Handlers
      • OroWindowsBundle
      • OroWorkflowBundle
      • OroCatalogBundle
      • OroCheckoutBundle
      • OroCMSBundle
        • Content Blocks
        • Widgets on a CMS Content Page
      • OroCustomerBundle
      • OroFrontendBundle
      • OroInventoryBundle
      • OroOrderBundle
      • OroPayPalBundle
      • OroPricingBundle
        • Configure Price List Sharding
        • Optimize Website Indexation and Price Recalculation
        • Combined Price List
        • Price Storage
        • Pricing Strategy
      • OroProductBundle
        • Product Actions
        • Customize Products Using Layouts
          • Customize Product View Page
          • Customize Product List Page
          • Customize Products SKU Validation
        • Product Attributes
        • Product Unit Formatting
        • Product Variant Search
        • Related Items
      • OroSEOBundle
        • Sitemap
        • SEO Meta Fields
      • OroTaxBundle
      • OroWebCatalogBundle
      • OroWebsiteSearchBundle
Version:
3.1
  • 4.1
  • 4.2 (latest)
  • 5.0 Alpha 1 (master)
  • Contents
    • How It Works
    • Search Index Data
    • Extension Points

Product Variant Search

This document describes search index behavior when a user is looking for for a configurable product or a product variant and finds the configurable product by the values from the assigned product variants. Here, you can also find what data is stored in the search index and how to customize it.

How It Works

When a user creates a configurable product, they associate it with several simple products called product variants. These variants should have different values for the configurable product attribute so that the application can identify the appropriate product variant by the value of the configurable product attribute.

When a user performs search in the application storefront, they should be able to find a configurable product by the values from the associated product variants. This feature works for the global search (all text), select and multi-select fields.

For instance, you could have three simple products with the TAG1, TAG2, and TAG3 SKUs, one configurable product with the SKU set to GENERAL-TAG. In addition, there could be two attributes, Color (of the select type) and Material (of the multi-select type). Both attributes are searchable and filterable. Color is used as a configurable product attribute. The illustration for this example is below:

Product SKU: TAG1
Color: Red
Material: Paper, Plastic

Product SKU: TAG2
Color: Green
Material: Paper

Product SKU: TAG3
Color: Blue
Material: Plastic

Product SKU: GENERAL-TAG
Color: empty
Material: empty

Here, we can have two scenarios:

  • When product variants are invisible in the storefront (which is the default behavior)
  • When product variants are visible (this behavior has to be set manually in the system configuration).

The first table below illustrates the behavior when product variants are invisible.

Filter Value Found products
All text TAG1 GENERAL-TAG
All text TAG2 GENERAL-TAG
All text TAG3 GENERAL-TAG
All text TAG4  
All text GENERAL-TAG GENERAL-TAG
Color Red GENERAL-TAG
Color Green GENERAL-TAG
Color Blue GENERAL-TAG
Color White  
All text Red GENERAL-TAG
All text Green GENERAL-TAG
All text Blue GENERAL-TAG
All text White  
Material Paper GENERAL-TAG
Material Plastic GENERAL-TAG
Material Metal  
All text Paper GENERAL-TAG
All text Plastic GENERAL-TAG
All text Metal  

Here, a configurable product can be found by the values both from the configurable product and associated product variants.

The second table illustrates the application behavior when product variants are visible.

Filter Value Found products
All text TAG1 GENERAL-TAG, TAG1
All text TAG2 GENERAL-TAG, TAG2
All text TAG3 GENERAL-TAG, TAG3
All text TAG4  
All text GENERAL-TAG GENERAL-TAG
Color Red GENERAL-TAG, TAG1
Color Green GENERAL-TAG, TAG2
Color Blue GENERAL-TAG, TAG3
Color White  
All text Red GENERAL-TAG, TAG1
All text Green GENERAL-TAG, TAG2
All text Blue GENERAL-TAG, TAG3
All text White  
Material Paper GENERAL-TAG, TAG1, TAG2
Material Plastic GENERAL-TAG, TAG1, TAG3
Material Metal  
All text Paper GENERAL-TAG, TAG1, TAG2
All text Plastic GENERAL-TAG, TAG1, TAG3
All text Metal  

As we can see, both the configurable product and product variants can be found using the values from the product variants.

Keep in mind that configurable products can be found not only by the configurable attribute filter (e.g., Color = Green), but also by the text representation of the appropriate option (e.g., All text = Green).

Search Index Data

Once you understand the expected behavior, you can check the search index data to find out how the application implements this behavior.

Using the same example with the tag products from the previous section, we can check what data we have in the search index:

TAG1

1
2
3
4
5
6
7
8
{
    "sku" : "TAG1",
    "is_variant" : "1",
    "all_text_1" : "TAG1 Red Paper Plastic",
    "color_red" : "1",
    "material_paper" : "1",
    "material_plastic" : "1"
}

TAG2

1
2
3
4
5
6
7
{
    "sku" : "TAG2",
    "is_variant" : "1",
    "all_text_1" : "TAG2 Green Paper",
    "color_green" : "1",
    "material_paper" : "1"
}

TAG3

1
2
3
4
5
6
7
{
    "sku" : "TAG3",
    "is_variant" : "1",
    "all_text_1" : "TAG3 Blue Plastic",
    "color_blue" : "1",
    "material_plastic" : "1"
}

GENERAL-TAG

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
    "sku" : "GENERAL-TAG",
    "is_variant" : "0",
    "all_text_1" : "GENERAL-TAG TAG1 TAG2 TAG3 Red Green Blue Paper Plastic",
    "color_red" : "1",
    "color_green" : "1",
    "color_blue" : "1",
    "material_paper" : "1",
    "material_plastic" : "1"
}

As illustrated in the example above, configurable product includes text, select, and multi-select attribute values from the product variants. So, when the application executes search query with the all_text_1 ~ TAG1 or color_red = 1 restrictions, both the configurable product and the product variant are found.

Extension Points

The logic that adds product variant data to the configurable product is encapsulated in the Oro\Bundle\ProductBundle\Search\ProductVariantProviderDecorator class. This class decorates the Oro\Bundle\ProductBundle\Search\WebsiteSearchProductIndexDataProvider standard data provider and adds the text, select, and multi-select attribute values of a product variant to the configurable product.

If you need to change this behavior or the logic of data collection, create another data provider decorator that implements the Oro\Bundle\ProductBundle\Search\ProductIndexDataProviderInterface interface which changes the search index data. Next, decorate the original provider in the DI container.

Here is an example of how you can implement this:

1
2
3
4
5
6
7
 services:
     oro_product.provider.website_search_index_data.product_variants:
         class: Oro\Bundle\ProductBundle\Search\ProductVariantProviderDecorator
         decorates: 'oro_product.provider.website_search_index_data'
         decoration_inner_name: 'oro_product.provider.website_search_index_data.original'
         arguments:
             - '@oro_product.provider.website_search_index_data.original'
Oro Documentation
  • Oro inc
  • Orocommerce
  • Orocrm
  • Oroplatform
  • Partners
  • Services
  • Events
  • Terms & conditions
  • Privacy policy
  • Contributor license agreement

@2021 Oro, Inc. All Rights Reserved.

Back to top