I am trying to get the product collection based on the position (defined in Category Products in admin) in the category, but it doesn't work with product collection object whereas works correctly with product collection array (getData())
E.g. in Admin > Manage Categories > Category > Category Products
(Is Anchor = true but no sub-categories)
Product | Position
Prod A | 1
Prod B | 2
When I loop through product collection $_productCollection
in catalog/product/list.phtml file, the product's order comes Prod B and then Prod A, whereas if I use $_productCollection->getData()
and loop through it, it gives products in correct order.
foreach($_productCollection as $_product) //gives Prod B and then Prod A, which is not expected
foreach($_productCollection->getData() as $_product) //gives Prod A and then Prod B, which is correct
Any ideas why it would behave differently when accessing it as an object and as an array, on the same collection?
Thanks!
foreach($_productCollection as $_product)
. Actually it did got auto-fixed but not sure whether this problem will start again or not.