Timeline for Difference between $this->helper('catalog/image')->... vs. (string)$this->helper('catalog/image')->
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 3, 2016 at 16:11 | comment | added | Pitt | if you have to manipulate the url of the cached resized image, like doing a substr match and editing the url, it will be more efficient to cast the helper image object to string. Otherwise every time that substr is called on the object a __toString() is called, which affects performance quite a bit if you do it often. | |
Sep 17, 2013 at 20:33 | comment | added | laketuna | Now I remember about the magic function.. I seem to regularly forget about this. Def need to use need to use OOP more. I see it in Mage_Catalog_Helper_Image where it returns the string URL. | |
Sep 17, 2013 at 20:32 | vote | accept | laketuna | ||
Sep 17, 2013 at 20:27 | comment | added | Marius♦ |
when calling echo on an object PHP tries to convert it to string so it calls the same __toString method.
|
|
Sep 17, 2013 at 20:24 | comment | added | laketuna |
Regarding the memory usage, simply assigning $this->helper()->... to a variable allocates ~500MB of memory on certain products. I have a post here: magento.stackexchange.com/questions/8113/…. But I do need to run some more tests to cases.
|
|
Sep 17, 2013 at 20:22 | comment | added | laketuna |
Ah, does __toStrign() work the same for string-casting inside PHP and when echo ing in HTML?
|
|
Sep 17, 2013 at 20:19 | history | answered | Marius♦ | CC BY-SA 3.0 |