Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filters of reference data attributes not working in product_model_index #214

Open
jotalops opened this issue Apr 16, 2020 · 0 comments
Open

Comments

@jotalops
Copy link

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

@jotalops jotalops changed the title reference data filters in product_model_index by reference not working reference data filters of reference data attributes not working in product_model_index Apr 16, 2020
@jotalops jotalops changed the title reference data filters of reference data attributes not working in product_model_index filters of reference data attributes not working in product_model_index Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant