on 07-23-2017 4:49 AM
Running into a strange issue where only the first product document created as part of a SOLR index contains updated facet values and newly added property values. It doesn't matter which product is the first to be indexed as I've performed a full index, observed the problem, deleted the single product which was properly populated, rerun the index and observed that the next "first" product document in SOLR now contains the full dataset while the remaining product documents only contain the smaller set of fields. Even when using springELValueProvider for ootb attributes such as name or description will return null on every product but the first returned. Any suggestions or guidance would be appreciated. Thanks!
The attributes name
and description
for a product are localized and if they are not indexed, it probably means that the system returns null
because no text has been defined for the current locale. I assume that the locale is properly set when the indexing starts and that's why the values are properly indexed for the first product. But between the first and the second product, something changes the current locale and set it to another locale, for which no text has been defined for the name
and description
attributes.
The productUrlValueProvider
is a possible culprit. Its method getProductUrl
changes the current locale to get the product URL but does not revert back to the original current locale. If you use this value provider, it could be the reason for your problems. If you need to use this value provider, here is a possible fix:
public class NonDisruptiveProductUrlValueProvider extends ProductUrlValueProvider
{
private SessionService sessionService;
@Override
protected String getProductUrl(final ProductModel product, final LanguageModel language)
{
return sessionService.executeInLocalView(new SessionExecutionBody()
{
@Override
public Object execute()
{
return NonDisruptiveProductUrlValueProvider.super.getProductUrl(product, language);
}
});
}
protected SessionService getSessionService()
{
return sessionService;
}
@Required
public void setSessionService(SessionService sessionService)
{
this.sessionService = sessionService;
}
}
It might not be the most efficient manner but it works (eventually a try/finally could be more efficient).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
you can also use the productUrlsValueResolver which is available OOTB.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.