cancel
Showing results for 
Search instead for 
Did you mean: 

Magento2 layer product collection returns inconsistent results

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Magento2 layer product collection returns inconsistent results

I'm running this code on my ListProduct page and the first time I get to the page, I might get 4 items. Then if I refresh the page, I'll get 6, then 4, then 5...etc I can't see any reason for this. I checked my query and it's always the same. If someone could point me in the right direction, that would be helpful.

 

$products = $layer->getProductCollection()
->addAttributeToFilter('part_number',array('in'=>$numbers))
->setVisibility($this->productVisibility->getVisibleInSiteIds());