Catalog Product Customer Attribute-Filter

Introduction

The "catalog product customer attribute filter"-extension for the Magento2.x supports dynamic product filtering via matching product- and customer-attribute values. Products with matching  values are available in the storefront - products with non matching values will be hidden or shown as "out of stock" (depending on the configuration) to the customer. 

E.g. If you want to show products to customers with matching languages, countries or sizes only.

Module

extension-name: enobis/module-catalog-product-customer-attribute-filter
  • Latest stable version

    version: 1.5.1
  • Install & Update

    First you need to add our private repo to your composer.json of your magento installation:

    composer config repositories.enobis-your-reponame composer https://satis.enobis.de/customers/your-reponame/

    Important: All repos are secured by an ip-protection or an user-authentication. Access Credentials are provided by us!

    To install the CHILIconnector-extension use composer via ssh:

    composer require enobis/extension-name

    To update the CHILIconnector-extension use composer via ssh:

    composer update enobis/extension-name

    Afterwards you have to complete your Magento2.x installation by

    php bin/magento setup:upgrade
    php bin/magento setup:di:compile
    php bin/magento setup:static-content:deploy
    php bin/magento cache:clean
    php bin/magento indexer:reindex
  • Changelog & Roadmap

    • 1.5.1 optimization - functionality to reduce the frontend layered navigation option values of an attribute, when that attribute is also used for visibility filtering. Remove option values that are not explicitly allowed for the current customer
    • 1.5.0 optimization, compatibility - performance optimization for account relation switcher module, possibility to define which account types are relevant for filtering, performance optimization for customers that are not relevant (website without filtering,or irrelevant account_type)
    • 1.4.1 bugfix - Display of Simple-Products in the DropDown when filtering is activated
    • 1.4.0 optimization -pre filter elastic search queries with permitted products (Magento requires elastic search starting with Version 2.4 and calculates aggregates partially direct from elastic results see https://orba.co/how-does-elasticsearch-work-with-magento/ for more info, this could effect toolbar sums and aggregate values in the layerd Navigation)
    • 1.3.1 optimization - Don't index or filter if module is enabled but no attributes are defined
    • 1.3.0 feature - Ability to define filter attributes in the backend configuration instead of former xml based configuration. XML-based configuration is supported too! Important: If xml-configuration exists, it will be used! To change it to the backend-configuration, please delete xml-configuration file.
    • 1.2.0 feature - support for campaign-extension (event)
    • 1.1.1 optimization - add seperate indexes for products and customers to speed up the indexing process
    • 1.1.0 optimization - magento 2.4.3 compatibility, extensive debug logging can be turned on and off, optimization avoid entries for products that are not enabled anywhere, optimization for multi website shops with disabled module on some websites, avoid entries for customers and products that are only on non filtered websites
    • 1.0.1 optimization - Allow html in "Customer Attribute Filter Responsible" attribute output, Add wysiwyg functionality to "Customer Attribute Filter Responsible" attribute
    • 1.0.0 Initial Release
  • Roadmap

    • Filtering with activated Caches (Catalog_Category, Catalog_Product, Catalog_Search) - right now, they must be deactivated to filter correctly.
    • "Stop Full Reindex Process" - Change to "Global Scope" in Backend
  • Prerequisites

    Qur extensions are not available via the magento-marketplace or packagist.org! The extensions are only available via a (private) repository!

    In order to get access, a valid license-agreement is required!

    If you have no access to our repositories, please contact us!

  • Addons

    The following modules are available as addons:

    • n/a
  • Support

    If you need help using the CHILIconnector, please get in touch with us by sending an email to support@enobis.de.

Features-Overview

Filtering

The Extension filters products dynamically by matching customer and product attribute values. "Dropdown"- and "MultipleSelect"-attribute values are supported.

Filtered products will be hidden (or shown as "out of stock" in 

  • catalog list / grid view
  • catalog search view
  • product detail page (configurable, bundle, grouped products)

A combination of several attributes as dynamic filters is possible. Each filter-attribute will be interpreted as an "and"-condition.

Indexing

The "dynamic filter"-functionality is based on an index table, which contains the "visibility" of the product. The index will be created and updated by different indexing mechnisms.

  • automatic indexing
    • after customer login (partial indexing for the customer)
    • after saving the customer (partial indexing for the customer and all products)
    • after saving the product (partial indexing for the products and all customers)
  • manual indexing
    • by console (complete indexing for all products and all customers)
    • by backend-function (complete indexing for all products and all customers)

Bestpractices & Faq

  • Faq - Filter Logics

    Frontend: Productlists / Widgets & Search Results

    • Simple products, virtual products, downloadable products will be hidden (out-of-stock) in the product list
    • Configurable product (product itself is filtered or all of its child products are filtered): product will be hidden in the product list by default. Until Magento 2.3.6 it is shown in the frontend instead. A configuration option enables "hiding" on older Magento version also.
    • Simple, virtual products(options) inside of configurable products will be hidden by default. A configuration option will show not available options. If no option is selectable, a message appears in the storefront.
    • Grouped products (product itself is filtered or all of its child products are filtered): product will be hidden in the product list
    • simple, virtual products inside of a grouped product will be displayed as "out of stock"
    • Bundle products (product itself is filtered or all of its child products are filtered): product will be hidden in the product list

    Backend

    No filtering in the backend - all products will be shown!
  • Faq - Indexers

    To filter products depending on matching attribute values (customer<->product), it is necessary to store appropiate information into an index-table. The indexer stores the data into the index-table. The index-process will be started

    • by saving the customer (or "Reindex product visibility"-button): This will reindex data for the corresponding customer only
    • by saving the product: This will reindex data for the corresponding product only
    • via console manually by
    bash php bin/magento indexer:reindex Enobis_CatalogProductCustomerAttributeFilter_VisibleProduct_Customer"

    This will reindex all data! Reindexing all data from the console is only necessary

    • after installing the extension and creating the index for the first time
    • after changing the  configuration of filter attributes

    Important: Reindexing could be time consuming task. E.g. If you have 1000 products and 100 customers the index contains 100.000 index rows.

    Note:  If you want to reindex the index automatically, please create a cron job which executes the

    bash php bin/magento indexer:reindex Enobis_CatalogProductCustomerAttributeFilter_VisibleProduct_Customer

    automatically.

    The following information are stored to the index-table `enobis_catalog_product_customer_attribute_filter_index`:

    • - customer[id]
    • - product [id]
    • - visibility[1,0]

    Products with visibility "0" act like "not saleable" products and will be filtered automatically through Magento.

  • Bestpractices

    1. Create a test product and test customer first
    2. Check if the product(s) and options are available in the storefront.
    3. Please create only one filter attribute first. Troubleshooting incorrectly configured customers, products and options can be very time-consuming!
    4. Create a filter configuration (from backend or via xml-configuration)
    5. Start indexing of the product-visibility for your customer only.

    Please go to the backend of Magento and select a customer account at "Customers->customer account" and start the index process for your customer only, by clicking on the "Reindex product visibility"-button. This reindexes only the product visibility for your customer! If everthing is ok, you can reindex the product visibility for all customers.

    Use the console for reindexing by 

    bash php bin/magento indexer:reindex Enobis_CatalogProductCustomerAttributeFilter_VisibleProduct_Customer 
    If everything works as expected, you can add new attributes to create more complex filtering scenarios.
  • Troubleshooting - Indexer runs very long - I want to stop the indexing process

    Possible solutions:

    • Stop reindex process from the backend

    Go to "System->Configuration->Enobis->Catalog Product Customer Attribute Filter" and use the "Stop Full Reindex Process"-Button.

    Check if the product(s) and options are available in the storefront.

    • Stop the reindex process by force

    - Disable the extension from the console

    bash

    php bin/magento module:disable Enobis_CatalogProductCustomerAttributeFilter
    php bin/magento module:upgrade
    php bin/magento module:di:compile
    php bin/magento cache:flush
    - kill php process in ssh-console
    kill (process_id)
    - Invalidate Indexer
    bash php bin/magento indexer:reset Enobis_CatalogProductCustomerAttributeFilter_VisibleProduct_Customer

Configuration

To activate the dynamic filtering mechanism at least two attributes (product, customer) with matching "attribute_codes" and "attribute values" are needed. The attributecode can be configured in the backend of Magento (new in version 1.3.0) or must be configured in a xml-based configuration file in your theme.

Important: 

  • Multiple attributes are supported
  • Only Dropdown and MultipleSelect-Attributes are supported for filtering!
  • Stores->Configuration->CHILI->CHILI-My Document

    OptionTypeDescriptionScope
    EnableYes, No (Default)Enable FilterSystem->Website
    Display Parent Products even all Child Products are filteredYes, No (Default)Display the Parent Product (e.g. Configurable Product) even all child products are filtered. By default the parent product will be filtered too. If it's enabled the parent product is shown in e.g. product listings etc.System->Website
    Hide filtered Child ProductsYes (Default), No

    Hides (default behaviour) the child product if it's filtered. If disabled, the filtered products will be shown as "out of stock" / "not available"

    System->Website
    Disable Full ReindexYes, No (Default)Disables the full reindex mechanism from the backend. System->Global
    AttributesMultiple-StringAttributecodes for filtering. Important: Only dropdown- and multiple-select-attributes are supported!System->Global
    Stop Full Reindex ProcessActionStops the reindex processSystem->Storeview (@Todo: Global Scope)
    Enable Debug LoggingYes, No (Default)Enables a debugging log. Debug log available at "/var/logs/debug.log"System->Global

    If everything is setup correctly, your configuration will be saved and you are now able to access some enviromental data in the other configuration tabs.

    Example configuration file (for version < 1.30):

    app/design/frontend/Magento/luma_child/Enobis_CatalogProductCustomerAttributeFilter/etc/catalog_product_customer_attribute_filter.xml

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:module:Enobis_CatalogProductCustomerAttributeFilter:etc/catalog_product_customer_attribute_filter.xsd">
    <attributes>
    <attribute name="EAV_ATTRIBUTE_CODE" />
    </attributes>
    </config>