I have Magento product collection with some filters. when i call $productCollection->getData() I have right result, but foreach($productCollection as $product) gives wrong products. why its happening?

  • please provide more data like your code. – kunj May 27 '18 at 11:11
  • 1
    try this: $productCollection->load(); foreach($productCollection as $product){ {{Your code }} } – kunj May 27 '18 at 11:36
  • Is tat worked fo you? – kunj May 27 '18 at 12:46
  • i try add price filter in 'catalog_block_product_list_collection' observer. after $collection->getSelect()->where([my condition]); i try collection->getData() and get array with right results, but if i use foreach($collection as $product) - i have wrong products, not same as array – Roman May 27 '18 at 15:39
  • what is right and wrong result, can you please help us with the output? – Yash Patadia May 28 '18 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.