Adding custom product attributes to Solr

An issue had come up in the product listing page where the pagination wasn’t working correctly. The pagination was set to 12 products per page, however, a seemingly random number or products between 0 and 12 would display in the product list page. Debugging revealed that the entire collection for the page was being loaded, however, the IDs being retrieved from Solr did not match with the product collection from Magento. This mismatch caused only a few products to appear in the page.

I tried to query Solr itself via curl:

curl http://localhost:8983/solr/select?q=*:*

which basically shows the entire collection. I checked if the product had a specific attribute that was being searched for and noticed that it wasn’t appearing. It seems like this attribute wasn’t being indexed in Solr.

A StackOverflow post stated that the product attribute needed to have “Use in product listing” and “Use in advanced search” for the attribute to be indexed in Solr. After this was enabled on the attribute and the product attributes were reindexed, the pagination was working correctly in the product listing page.

Leave a Reply

Your email address will not be published. Required fields are marked *