It seems wrong to me to put methods in the PHTML file. I need to loop through products in a PHTML file, but I want to call a method inside the
<?php $lastOrder = $this->getLatestOrder(); $orderItems = $lastOrder->getAllItems(); ?> <?php foreach($orderItems as $item): ?> html stuff... <?php $this->getCategoryNames($item->getId()); // this doesn't work ?> <?php endforeach; ?>
Using the code above, the
getId() is always NULL in the block controller.
What is the best way to do this? Does the logic belong in the PHTML file? Should I use the
Mage::registry 'globals'? I've tried
getData, but they don't seem to work inside a loop (reassignment issues). Thanks!