Skip to content

filters of reference data attributes not working in product_model_index  #214

@jotalops

Description

@jotalops

In version 2.4 of the bundle ( akeneo 2.3 )

if we do a simple search by an attribute of type reference data simple or multiple we dont't found any results.

+++++++++++++++++
$pqbFactory = $this->getContainer()->get('pim_catalog.query.product_model_query_builder_factory');

/* @var ProductAndProductModelQueryBuilder $pqb */
$pqb = $pqbFactory->create(['default_locale' => 'en_US', 'default_scope' => 'ecommerce']);
$pqb->addFilter('rd_brand', 'IN', [$brandCode]);

+++++++++++++++++

debugging the error I found that the index product_model_index is not used by the reference data normalizers

to resolve the issue we must add that index to the normalizers:

ReferenceDataCollectionNormalizer.php
ReferenceDataNormalizer.php

we must include in the supportsNormalization method that index

....
use Pim\Component\Catalog\Normalizer\Indexing\ProductModel\ProductModelNormalizer as ProductModelNormalizer2;

....
public function supportsNormalization($data, $format = null)
{
return $data instanceof ReferenceDataCollectionValue && (
ProductNormalizer::INDEXING_FORMAT_PRODUCT_INDEX === $format ||
ProductModelNormalizer::INDEXING_FORMAT_PRODUCT_AND_MODEL_INDEX === $format
|| ProductModelNormalizer2::INDEXING_FORMAT_PRODUCT_MODEL_INDEX
);
}
......
public function supportsNormalization($data, $format = null)
{
return $data instanceof ReferenceDataValue && (
ProductNormalizer::INDEXING_FORMAT_PRODUCT_INDEX === $format ||
ProductModelNormalizer::INDEXING_FORMAT_PRODUCT_AND_MODEL_INDEX === $format
|| ProductModelNormalizer2::INDEXING_FORMAT_PRODUCT_MODEL_INDEX
);
}

I attached the fix

ProductValue.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions