I'm working on cleaning up some codes where the previous person wrote a whole bunch of PHP code in PHTML files. So, for example, I made the PHP code put in list.phtml
as part of the overriden List.php
.
Now, I'm looking at view.phtml
for the product-view page, and it calls a lot of child HTMLs. In particular, I'm looking at media.phtml
and configurable.phtml
, where there is very similar set of PHP codes. How can I integrate these PHP codes into one place (similar to what I did with List.php
), so that each of these PHTML can call the same function (for example, getProductUrls()
)?
Additionally, is it possible to have variables available in media.phtml
also available in configurable.phtml
without having to call getProductUrls()
twice (once in media and once in configurable)?