services:
    oro_catalog.category_tree_handler:
        class: 'Oro\Bundle\CatalogBundle\JsTree\CategoryTreeHandler'
        arguments:
            - 'Oro\Bundle\CatalogBundle\Entity\Category'
            - '@doctrine'
            - '@oro_security.token_accessor'
            - '@oro_catalog.provider.category_tree_provider'
            - '@oro_catalog.provider.master_catalog_root'

    Oro\Bundle\CatalogBundle\JsTree\CategoryTreeHandler:
        alias: 'oro_catalog.category_tree_handler'

    oro_catalog.provider.category_tree_provider:
        class: 'Oro\Bundle\CatalogBundle\Provider\CategoryTreeProvider'
        public: false
        arguments:
            - '@doctrine'
            - '@event_dispatcher'
            - '@oro_catalog.provider.master_catalog_root'

    oro_catalog.provider.subcategory_provider:
        class: 'Oro\Bundle\CatalogBundle\Provider\SubcategoryProvider'
        public: false
        arguments:
            - '@oro_security.token_accessor'
            - '@oro_catalog.provider.category_tree_provider'

    oro_catalog.provider.category_entity_name:
        class: 'Oro\Bundle\CatalogBundle\Provider\CategoryEntityNameProvider'
        public: false
        tags:
            - { name: oro_entity.name_provider, priority: 100 }

    oro_catalog.event_listener.form_view:
        class: 'Oro\Bundle\CatalogBundle\EventListener\FormViewListener'
        arguments:
            - '@translator'
            - '@oro_entity.doctrine_helper'
            - '@security.authorization_checker'
        calls:
            - [setFieldAclHelper, ['@oro_security.form.field_acl_helper']]
        tags:
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.product-view, method: onProductView }
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.product-edit, method: onProductEdit }
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.product-create-step-one, method: onProductEdit }

    oro_catalog.event_listener.datagrid:
        class: 'Oro\Bundle\CatalogBundle\EventListener\DatagridListener'
        arguments:
            - "@doctrine"
            - "@oro_catalog.handler.request_product"
        calls:
            - [setDataClass, ['Oro\Bundle\CatalogBundle\Entity\Category']]
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.pre.products-grid, method: onPreBuildProducts }
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.products-select-grid, method: onBuildBeforeProductsSelect }

    oro_catalog.event_listener.datagrid.export:
        class: 'Oro\Bundle\CatalogBundle\EventListener\ExportDatagridListener'
        arguments:
            - '@doctrine'
            - '@oro_catalog.datagrid.export.category_filter.registry'
        tags:
            - { name: kernel.event_listener, event: oro.import_export.before_get_ids, method: onBeforeExportGetIds }

    oro_catalog.event_listener.product_duplicate:
        class: 'Oro\Bundle\CatalogBundle\EventListener\ProductDuplicateListener'
        calls:
            - [setCategoryClass, ['Oro\Bundle\CatalogBundle\Entity\Category']]
            - [setDoctrineHelper, ["@oro_entity.doctrine_helper"]]
        tags:
            - { name: kernel.event_listener, event: oro_product.product.duplicate.after, method: onDuplicateAfter }

    oro_catalog.event_listener.abstract_product_import:
        class: 'Oro\Bundle\CatalogBundle\EventListener\AbstractProductImportEventListener'
        abstract: true
        arguments:
            - '@doctrine'
            - '@oro_security.acl_helper'
            - 'Oro\Bundle\CatalogBundle\Entity\Category'

    oro_catalog.event_listener.product_strategy:
        class: 'Oro\Bundle\CatalogBundle\EventListener\ProductStrategyEventListener'
        parent: oro_catalog.event_listener.abstract_product_import
        tags:
            - { name: kernel.event_listener, event: oro_product.strategy.process_after, method: onProcessAfter }
            - { name: doctrine.event_listener, event: onClear }

    oro_catalog.event_listener.product_data_converter:
        class: 'Oro\Bundle\CatalogBundle\EventListener\ProductDataConverterEventListener'
        tags:
            - { name: kernel.event_listener, event: oro_product.data_converter.backend_header, method: onBackendHeader }

    oro_catalog.event_listener.product_normalizer:
        class: 'Oro\Bundle\CatalogBundle\EventListener\ProductNormalizerEventListener'
        parent: oro_catalog.event_listener.abstract_product_import
        tags:
            - { name: kernel.event_listener, event: oro_product.normalizer.normalizer, method: onNormalize }
            - { name: doctrine.event_listener, event: onClear }

    oro_catalog.handler.request_product:
        class: 'Oro\Bundle\CatalogBundle\Handler\RequestProductHandler'
        arguments:
            - "@request_stack"

    Oro\Bundle\CatalogBundle\Handler\RequestProductHandler:
        alias: 'oro_catalog.handler.request_product'

    oro_catalog.provider.default_product_unit_provider.category:
        class: 'Oro\Bundle\CatalogBundle\Provider\CategoryDefaultProductUnitProvider'
        public: false
        tags:
            - { name: oro_product.default_product_unit_provider, priority: 10 }

    oro_catalog.event_listener.datagrid.category_filtering:
        class: 'Oro\Bundle\CatalogBundle\EventListener\SearchCategoryFilteringEventListener'
        arguments:
            - "@oro_catalog.handler.request_product"
            - "@doctrine"
            - '@oro_catalog.provider.subcategory_provider'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.pre.frontend-product-search-grid, method: onPreBuild }
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.frontend-product-search-grid, method: onBuildAfter }

    oro_catalog.datagrid.subcategory_filter:
        class: 'Oro\Bundle\CatalogBundle\Datagrid\Filter\SubcategoryFilter'
        public: false
        arguments:
            - '@form.factory'
            - '@oro_filter.filter_utility'
        tags:
            - { name: oro_search.extension.search_filter.filter, type: subcategory }

    oro_catalog.manager.product_index_scheduler:
        class: 'Oro\Bundle\CatalogBundle\Manager\ProductIndexScheduler'
        public: false
        arguments:
            - '@doctrine'
            - '@oro_product.search.product_reindex_manager'

    oro_catalog.event_listener.orm.category_listener:
        class: 'Oro\Bundle\CatalogBundle\EventListener\ORM\CategoryListener'
        public: false
        arguments:
            - '@oro_catalog.model.category_materialized_path_modifier'
        tags:
            - { name: doctrine.orm.entity_listener, entity: 'Oro\Bundle\CatalogBundle\Entity\Category', event: postPersist }
            - { name: doctrine.event_listener, event: onFlush }

    oro_catalog.model.category_materialized_path_modifier:
        class: 'Oro\Bundle\CatalogBundle\Model\CategoryMaterializedPathModifier'
        public: false
        arguments:
            - '@oro_entity.doctrine_helper'

    oro_catalog.event_listener.website_search_index:
        class: 'Oro\Bundle\CatalogBundle\EventListener\WebsiteSearchCategoryIndexerListener'
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_website.provider.website_localization'
            - '@oro_website_search.manager.website_context_manager'
        tags:
            - { name: kernel.event_listener, event: oro_website_search.event.index_entity.product, method: onWebsiteSearchIndex }

    oro_catalog.entity_listener.category:
        class: 'Oro\Bundle\CatalogBundle\Entity\EntityListener\CategoryEntityListener'
        public: false
        arguments:
            - '@oro_catalog.manager.product_index_scheduler'
            - '@oro_catalog.layout.data_provider.category.cache'
        tags:
            - { name: doctrine.orm.entity_listener, entity: 'Oro\Bundle\CatalogBundle\Entity\Category', event: preUpdate }
            - { name: doctrine.orm.entity_listener, entity: 'Oro\Bundle\CatalogBundle\Entity\Category', event: preRemove }
            - { name: doctrine.orm.entity_listener, entity: 'Oro\Bundle\CatalogBundle\Entity\Category', event: postPersist }

    oro_catalog.event_listener.products_change_relation:
        class: 'Oro\Bundle\CatalogBundle\EventListener\ProductsChangeRelationListener'
        public: false
        arguments:
            - '@event_dispatcher'
        tags:
            - { name: doctrine.event_listener, event: onFlush }

    oro_catalog.content_variant_type.category_page:
        class: Oro\Bundle\CatalogBundle\ContentVariantType\CategoryPageContentVariantType
        public: false
        arguments:
            - '@security.authorization_checker'
            - '@property_accessor'
        tags:
            - { name: oro_web_catalog.content_variant_type }

    oro_catalog.provider.routing_information_provider:
        class: Oro\Bundle\CatalogBundle\Provider\CategoryRoutingInformationProvider
        public: false
        arguments:
            - '@oro_config.global'
        tags:
            - { name: oro_redirect.routing_information_provider, alias: 'Oro\Bundle\CatalogBundle\Entity\Category' }

    oro_catalog.provider.catalog_context_url_provider:
        class: Oro\Bundle\CatalogBundle\Provider\CategoryContextUrlProvider
        public: false
        arguments:
            - '@request_stack'
            - '@oro_redirect.url_cache'
            - '@oro_locale.provider.current_localization'
        tags:
            - { name: oro_redirect.context_url_provider, alias: 'category' }

    oro_catalog.provider.products_content_variant_provider:
        class: Oro\Bundle\CatalogBundle\Provider\ProductsContentVariantProvider
        tags:
            - { name: oro_web_catalog.content_variant_provider }

    oro_catalog.event_listener.restrict_content_variant_by_category:
        class: Oro\Bundle\CatalogBundle\EventListener\RestrictContentVariantByCategoryEventListener
        arguments:
            - '@request_stack'
        tags:
            - { name: kernel.event_listener, event: oro_web_catalog.restrict_content_variant_by_entity, method: applyRestriction }

    oro_catalog.event_listener.category_content_variant_index:
        class: 'Oro\Bundle\CatalogBundle\EventListener\CategoryContentVariantIndexListener'
        arguments:
            - '@oro_catalog.manager.product_index_scheduler'
            - '@property_accessor'
            - '@oro_entity.doctrine.field_updates_checker'
            - '@?oro_web_catalog.provider.web_catalog_usage_provider'
        tags:
            - { name: doctrine.event_listener, event: onFlush }

    oro_catalog.visibility.default_product_options:
        class: 'Oro\Bundle\CatalogBundle\Visibility\BasicCategoryDefaultProductUnitOptionsVisibility'
        public: false

    oro_catalog.visibility.single_unit_default_product_options_decorator:
        class: 'Oro\Bundle\CatalogBundle\Visibility\SingleUnitCategoryDefaultProductUnitOptionsVisibilityDecorator'
        decorates: oro_catalog.visibility.default_product_options
        decoration_priority: 10
        arguments:
            - '@.inner'
            - '@oro_product.service.single_unit_mode'

    oro_catalog.config.event_listener.direct_url_prefix_change:
        class: Oro\Bundle\RedirectBundle\EventListener\ConfigRegenerateDirectUrlListener
        arguments:
            - '@oro_config.manager'
            - '@oro_message_queue.client.message_producer'
            - '@oro_redirect.form.storage.redirect_storage'
            - '@oro_redirect.direct_url_message_factory'
            - 'oro_catalog.category_direct_url_prefix'
            - 'Oro\Bundle\CatalogBundle\Entity\Category'
        tags:
            - { name: kernel.event_listener, event: oro_config.update_after, method: onUpdateAfter }

    oro_catalog.category_path.placeholder:
        class: 'Oro\Bundle\CatalogBundle\Placeholder\CategoryPathPlaceholder'
        public: false
        tags:
            - { name: website_search.placeholder }

    oro_catalog.category_counts.cache_provider:
        public: false
        parent: oro.data.cache
        tags:
            - { name: 'cache.pool', namespace: 'oro_catalog_category_counts' }

    oro_catalog.category_counts.cache:
        class: 'Oro\Bundle\CatalogBundle\Datagrid\Cache\CategoryCountsCache'
        public: false
        arguments:
            - '@oro_catalog.category_counts.cache_provider'
            - '@oro_security.token_accessor'
            - '@oro_website.manager'

    oro_catalog.datagrid.extension.category_counts:
        class: 'Oro\Bundle\CatalogBundle\Datagrid\Extension\CategoryCountsExtension'
        arguments:
            - '@oro_datagrid.datagrid.manager.link'
            - '@doctrine'
            - '@oro_catalog.website_search.repository.product'
            - '@oro_catalog.category_counts.cache'
            - '@oro_datagrid.tools.parameters_helper'
            - '@oro_config.manager'
        calls:
            - [addApplicableGrid, ['frontend-product-search-grid']]
        tags:
            - { name: oro_datagrid.extension }

    oro_catalog.website_search.repository.product:
        class: 'Oro\Bundle\CatalogBundle\Search\ProductRepository'
        parent: oro_website_search.repository.abstract
        calls:
            - [setEntityName, ['Oro\Bundle\ProductBundle\Entity\Product']]

    oro_catalog.entity_metadata_builder.product:
        class: 'Oro\Bundle\CatalogBundle\EventListener\ORM\ProductMetadataBuilder'
        tags:
            - { name: oro_entity_extend.entity_metadata_builder }

    oro_catalog.event_listener.tree:
        decorates: stof_doctrine_extensions.listener.tree
        class: Oro\Bundle\CatalogBundle\EventListener\TreeListener
        calls:
            - ['setAnnotationReader', ['@annotation_reader']]

    oro_catalog.provider.master_catalog_root:
        class: 'Oro\Bundle\CatalogBundle\Provider\MasterCatalogRootProvider'
        arguments:
            - '@doctrine'
            - '@oro_security.acl_helper'

    Oro\Bundle\CatalogBundle\Provider\MasterCatalogRootProvider:
        alias: 'oro_catalog.provider.master_catalog_root'

    oro_catalog.event_listener.organization_persist:
        class: 'Oro\Bundle\CatalogBundle\EventListener\ORM\OrganizationPersistListener'
        arguments:
            - '@oro_entity.doctrine_helper'
        public: false
        tags:
            - { name: doctrine.orm.entity_listener, entity: 'Oro\Bundle\OrganizationBundle\Entity\Organization', event: prePersist }

    oro_catalog.access_rule.frontend_organization_for_category:
        class: Oro\Bundle\OrganizationBundle\Acl\AccessRule\OrganizationAwareAccessRule
        arguments:
            - '@oro_organization.organization_restriction_provider'
        tags:
            - { name: oro_security.access_rule, entityClass: Oro\Bundle\CatalogBundle\Entity\Category, frontend: true }

    oro_catalog.provider.category_slug_source_entity:
        class: Oro\Bundle\CatalogBundle\Provider\CategorySlugSourceEntityProvider
        arguments:
            - '@oro_redirect.sluggable_entity_finder'
            - '@oro_config.manager'
        tags:
            - { name: oro_redirect.slug_source_entity_provider }

    oro_catalog.event_listener.category_strategy.empty_slug:
        class: Oro\Bundle\CatalogBundle\EventListener\EmptySlugCategoryStrategyEventListener
        arguments:
            - '@oro_entity_config.slug.generator'
        tags:
            - { name: kernel.event_listener, event: Oro\Bundle\CatalogBundle\ImportExport\Event\CategoryStrategyAfterProcessEntityEvent, method: onProcessAfter }

    oro_catalog.event_listener.category_preloading:
        parent: oro_entity.event_listener.default_preloading
        tags:
            - { name: kernel.event_listener, event: oro_entity.preload_entity.category, method: onPreload }

    oro_catalog.event_listener.config.original_filenames_config_update:
        class: Oro\Bundle\ConfigBundle\EventListener\ClearCacheOnConfigUpdateListener
        arguments:
            - 'oro_attachment.original_file_names_enabled'
        calls:
            - [addCacheToClear, ['@oro_catalog.layout.data_provider.category.cache']]
        tags:
            - { name: kernel.event_listener, event: oro_config.update_after, method: onUpdateAfter }

    oro_catalog.event_listener.datagrid.frontend_category_sort_order:
        class: Oro\Bundle\CatalogBundle\EventListener\FrontendCategorySortOrderDatagridListener
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.search_datasource.result.before.frontend-product-search-grid, method: onSearchResultBefore }

    oro_catalog.datagrid.export.category_filter.registry:
        class: Oro\Bundle\CatalogBundle\ImportExport\Datagrid\CategoryFilterRegistry
        calls:
            - [add, ['@oro_catalog.datagrid.export.category_filter.default']]

    oro_catalog.datagrid.export.category_filter.default:
        class: Oro\Bundle\CatalogBundle\ImportExport\Datagrid\DefaultCategoryFilter

    oro_catalog.event_listener.search.add_category_to_product_autocomplete:
        class: 'Oro\Bundle\CatalogBundle\EventListener\Search\AddCategoryToProductAutocompleteListener'
        arguments:
            - '@router'
            - '@oro_ui.twig.html_tag'
            - '@oro_config.manager'
        tags:
            - { name: kernel.event_listener, event: Oro\Bundle\ProductBundle\Event\ProcessAutocompleteQueryEvent, method: onProcessAutocompleteQuery }
            - { name: kernel.event_listener, event: Oro\Bundle\ProductBundle\Event\ProcessAutocompleteDataEvent, method: onProcessAutocompleteData }

    oro_catalog.menu.menu_categories_provider:
        class: Oro\Bundle\CatalogBundle\Menu\MenuCategoriesProvider
        arguments:
            - '@oro_catalog.provider.category_tree_provider'

    oro_catalog.menu.menu_categories_caching_provider:
        class: Oro\Bundle\CatalogBundle\Menu\MenuCategoriesCachingProvider
        decorates: oro_catalog.menu.menu_categories_provider
        arguments:
            - '@.inner'
            - '@oro_customer.provider.customer_user_relations_provider'
            - '@oro_security.token_accessor'
        calls:
            - [setCache, ['@oro_catalog.menu.menu_categories_cache', 3600]]

    oro_catalog.menu.menu_categories_cache:
        class: Oro\Bundle\CatalogBundle\Menu\MenuCategoriesCache
        arguments:
            - '@oro_catalog.layout.data_provider.category.cache'
            - '@oro_locale.cache.normalizer.localized_fallback_value_collection'

    oro_catalog.provider.form_template_data.return_action:
        class: Oro\Bundle\CatalogBundle\Provider\CategoryFormTemplateDataProvider
        arguments:
            - '@oro_catalog.utils.sort_order_dialog_target_storage'
        tags:
            - { name: oro_form.form_template_data_provider, alias: category_form_template }

    Oro\Bundle\CatalogBundle\Provider\CategoryFormTemplateDataProvider:
        alias: oro_catalog.provider.form_template_data.return_action

    oro_catalog.event_listener.form_handler.sort_order_dialog_target:
        class: Oro\Bundle\CatalogBundle\EventListener\SortOrderDialogTargetFormHandlerEventListener
        arguments:
            - '@oro_catalog.utils.sort_order_dialog_target_storage'
            - '@oro_ui.router'
            - '@property_accessor'
        tags:
            - { name: kernel.event_listener, event: oro_catalog.category.edit, method: onFormAfterFlush }

    oro_catalog.utils.sort_order_dialog_target_storage:
        class: Oro\Bundle\CatalogBundle\Utils\SortOrderDialogTargetStorage
        arguments:
            - '@request_stack'
