Oro Documentation
Oro Documentation
  • USERS
  • DEVELOPERS
    • Backend Developer Guide
    • Frontend Developer Guide
    • Bundles & Components
    • Web Services API Guide
    • Community Guide
  • CLOUD
  • BLOG
  • ACADEMY
  • Home >
  • Oro Bundles and Components >
  • OroProductBundle >
  • Product Variant Search
  • Oro Bundles and Components
    • Components
      • Configuration Merger
      • Cumulative Resources
      • System Aware Resolver
    • ActionBundle
    • ActivityBundle
      • Commands
    • ActivityListBundle
    • AddressBundle
    • ApiBundle
    • AssetBundle
      • Commands
    • AttachmentBundle
      • OroAttachmentBundle Configuration
      • Displaying Pictures
      • Generating Image and File URLs
      • Image Placeholder Configuration
    • BatchBundle
    • CacheBundle
    • CalendarBundle
      • Calendar Provider
      • Calendar Context Menu
      • System Calendars
      • Workflow Action
      • Recurring Events
      • UID (Unique Calendar Identifier)
      • Calendar Event Ownership
      • Attendees
    • ChartBundle
    • CookieConsentBundle
    • CommentBundle
    • ConfigBundle
    • CronBundle
    • CurrencyBundle
      • Multi Currency Cell Content Editor
    • DashboardBundle
    • DataAuditBundle
    • DataGridBundle
      • Default Editors
    • DistributionBundle
    • DigitalAssetBundle
    • ElasticSearchBundle
      • Index Agent and Search Engine
      • ElasticSearch Indexes Backup
      • ElasticSearch Configuration
      • Request Builders
      • Troubleshooting
      • Upgrade Website Index to Elasticsearch >=7.7, <8.0
    • EmailBundle
      • Transports
      • Events
      • Emails
      • Email Templates
      • Email Templates Migrations
      • System Mailboxes
      • Email Ownership
      • Sending Emails in Workflows and Actions (Operations)
      • Recipients Autocompletion
      • Public and Private Emails
      • Commands
    • EmbeddedFormBundle
    • EntityBundle
      • EntityModel
      • EntitySelectSearchApiAccessor ⇐ SearchApiAccessor
      • EntityStructureDataProvider
    • EntityConfigBundle
    • EntityExtendBundle
    • EntityMergeBundle
    • EntityPaginationBundle
    • EntitySerializedFieldsBundle
    • FeatureToggleBundle
    • FilterBundle
      • Filter Form Types
      • Grid Extension
    • FormBundle
      • Form Components Overview
      • Update Handler
      • Entity Create or Select Form Type
      • Rich Text Form Type
      • Autocomplete Form Type
      • Text Autocomplete Form Type
      • UI DataBlock Config Overview
      • Expression Editor
      • Client Side Validation
      • InlineEditableViewComponent
      • Index of Supported Editors
        • AbstractRelationEditorView
        • TextEditorView
        • NumberEditorView
        • PercentEditorView
        • DateEditorView
        • DatetimeEditorView
        • SelectEditorView
        • MultiSelectEditorView
        • MultiCheckboxEditorView
        • MultiRelationEditorView
        • RelatedIdRelationEditorView
        • RelatedIdSelectEditorView
      • Search APIs
    • GaufretteBundle
    • GridFSConfigBundle
    • ImapBundle
      • Usage Example
      • Synchronization with IMAP Servers
      • OAuth Providers for Mailboxes
      • User Email Origin Transport
    • ImportExportBundle
      • Commands
    • InstallerBundle
      • Commands
    • IntegrationBundle
    • LayoutBundle
      • Layout Cache
    • LocaleBundle
      • Locale Settings
      • Number Formatting
      • Date and Datetime Formatting
      • Name Formatting
      • Address Formatting
      • Localization
      • Managing Localizations
      • Current Localization
      • Localized Values
      • CLI Commands (LocaleBundle)
    • LoggerBundle
    • MessageQueueBundle
      • Commands
    • MigrationBundle
      • Commands
    • MicrosoftSyncBundle
    • NavigationBundle
      • Commands
    • NoteBundle
    • NotificationBundle
    • OAuth2ServerBundle
    • OrganizationBundle
    • PlatformBundle
      • Commands
    • QueryDesignerBundle
      • Query Designer Configuration
      • Condition Builder Component
    • RedisConfigBundle
      • Configure Redis Servers
      • Configure Application to Use Redis
    • ReportBundle
    • ScopeBundle
    • SearchBundle
      • ORM Search Engine
      • Search Relevance Weight
      • DateTimeFormatter
    • SecurityBundle
    • SegmentBundle
    • SidebarBundle
    • SyncBundle
      • Configuration
      • Client
      • Topics and Handlers
      • Authentication
      • Content Outdating
      • Origin Checking
      • Mediator Handlers
    • TagBundle
      • TagsEditorView
      • TagsView
    • TestFrameworkBundle
      • Additional Doctrine Events
    • ThemeBundle
    • TranslationBundle
      • Commands
    • TwigInspectorBundle
    • UIBundle
      • 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
    • WindowsBundle
    • WorkflowBundle
      • Commands
    • DraftBundle
      • How to Use Drafts
      • How to Use Draft ACL
      • How to Use the Draft Filter
      • How to Resolve Draft Conflicts
      • How to Use a Draft Extension
    • CatalogBundle
    • CheckoutBundle
    • CMSBundle
      • Content Widgets
      • WYSIWYG Field
        • How to Add WYSIWYG Field
        • How to Display a WYSIWYG Field
        • How to Change Textarea Field to WYSIWYG Field
        • WYSIWYG Field Validation
      • Content Blocks
      • Create Editor Components
    • ConsentBundle
      • Add the Customer Consents Field to a Form (Example)
      • Add the Agreements Step to a Custom Checkout Based on the Default Checkout Workflow (Example)
      • Add the Agreements Section to a Custom Checkout Based on the Single Page Checkout Workflow (Example)
    • CustomerBundle
    • FrontendBundle
      • Frontend Sessions and Debug Routes
      • Frontend Access
      • Set Up Mass Action in Datagrid
      • Sticky Panel View
      • Dom Relocation Global View
    • InventoryBundle
    • OrderBundle
      • Previously Purchased Products
    • PayPalBundle
    • PromotionBundle
    • PricingBundle
      • Configure Price List Sharding
      • Optimize Website Indexation and Price Recalculation
      • Combined Price List
      • Price Storage
      • Pricing Strategy
      • Commands
    • ProductBundle
      • Product Actions
      • Product Attributes
      • Product Unit Formatting
      • Product Variant Search
      • Related Items
      • Externally Stored Product Images
      • Product Customization Using Layouts
        • Customize Product View Page
        • Customize Product List Page
        • Customize Product Lists
        • Customize Products SKU Validation
    • RedirectBundle
    • SEOBundle
      • Sitemap
      • SEO Meta Fields
    • TaxBundle
    • WebCatalogBundle
    • WebsiteElasticSearchBundle
      • Website ElasticSearch Search Engine
      • Website ElasticSearch Configuration
      • Attributes Boost
      • Request Builders
      • Upgrade Website Index to Elasticsearch >=7.7, <8.0
      • Synonym Management
    • WebsiteSearchBundle
      • Website Search VS Regular Search
      • Website Search Configuration
      • Search Index Structure
      • Console Commands
      • Perform Search
      • Indexation Process
      • Reindexation During Platform Update
      • ORM Search Engine
      • Search Relevance Weight
      • Testing
    • ActivityContactBundle
    • AnalyticsBundle
    • ChannelBundle
    • SalesBundle
    • ApruveBundle
    • AuthorizeNetBundle
    • DotmailerBundle
    • DPDBundle
    • GoogleTagManagerBundle
    • InfinitePayBundle
    • MailchimpBundle
    • MakerBundle
    • PaypalExpressBundle
    • StripeBundle
  • 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

{
    "sku" : "TAG1",
    "is_variant" : "1",
    "all_text_1" : "TAG1 Red Paper Plastic",
    "color_red" : "1",
    "material_paper" : "1",
    "material_plastic" : "1"
}

TAG2

{
    "sku" : "TAG2",
    "is_variant" : "1",
    "all_text_1" : "TAG2 Green Paper",
    "color_green" : "1",
    "material_paper" : "1"
}

TAG3

{
    "sku" : "TAG3",
    "is_variant" : "1",
    "all_text_1" : "TAG3 Blue Plastic",
    "color_blue" : "1",
    "material_plastic" : "1"
}

GENERAL-TAG

{
    "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:

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
  • OroMarketplace
  • OroCRM
  • OroPlatform
  • Partners
  • Services
  • Events
  • Twitter
  • Terms & conditions
  • Privacy policy
  • Contributor license agreement

@2021 Oro, Inc. All Rights Reserved.

Back to top