I have a foreach loop that I am running over a Magento collection so I can run pull in the info for multiple patients (it's a pharmacy). However, after each iteration of the foreach loop, it returns the values for the first value in the collection every time. If I manually pass the values for what should be values 2, 3, 4, etc in the collection, it does work properly.
Here is my function.
<?php foreach($this->getPatients() as $pat): ?> <?php //Pass patient ID to the collection so it can filter by patient ID ?> <?php $autoreorderCollection = null; ?> <?php $patientId = $pat->getId(); ?> <?php $autoreorderCollection = $this->getCollection($patientId); ?> <?php echo $autoreorderCollection->getSize(); ?> <?php endforeach ?>
It returns the value for the first entity in the collection every time the foreach is iterated through. If I pass the value for the second entity manually, collection for that entity is returned. That tells me it's an issue with the foreach loop and not with the function. What am I doing wrong?