I am new to Magento. I have following code in a template file called brand.html

$brandImageUrl = $this->getBrandImageUrl($brand);

My understanding (roughly) is that $this refers to an instance of the block created by brand.html

Basically the image path returned by that method refers to an image that is too small and I would like to know where this method is is implemented so I can modify it to give me a path to a larger image. The image in question is a brand logo, currently at 40x19 pixels, which is too small.

Any pointers in the right direction are very welcome. Also general information for Magento newbies is welcome.

P.S. I have been programming for many years in many languages on many systems, but Magento is baffling me.

  • 1
    – Nickool
    Jun 22 '16 at 15:39

Two possibilities here:

Block method

The getBrandImageUrl is a method defined in the block.

To find out the class of the block you can call:


Magic method

The method getBrandImageUrl is a magic getter.

Thus it is not explicitely declared anywhere in the code.

As most of the Magento classes extend Varien_Object the code that makes that method available can be found under lib/Varien/Object.php :

public function __call($method, $args)
    switch (substr($method, 0, 3)) {
        case 'get' :
            //Varien_Profiler::start('GETTER: '.get_class($this).'::'.$method);
            $key = $this->_underscore(substr($method,3));
            $data = $this->getData($key, isset($args[0]) ? $args[0] : null);
            //Varien_Profiler::stop('GETTER: '.get_class($this).'::'.$method);
            return $data;

        case 'set' :
            //Varien_Profiler::start('SETTER: '.get_class($this).'::'.$method);
            $key = $this->_underscore(substr($method,3));
            $result = $this->setData($key, isset($args[0]) ? $args[0] : null);
            //Varien_Profiler::stop('SETTER: '.get_class($this).'::'.$method);
            return $result;

        case 'uns' :
            //Varien_Profiler::start('UNS: '.get_class($this).'::'.$method);
            $key = $this->_underscore(substr($method,3));
            $result = $this->unsetData($key);
            //Varien_Profiler::stop('UNS: '.get_class($this).'::'.$method);
            return $result;

        case 'has' :
            //Varien_Profiler::start('HAS: '.get_class($this).'::'.$method);
            $key = $this->_underscore(substr($method,3));
            //Varien_Profiler::stop('HAS: '.get_class($this).'::'.$method);
            return isset($this->_data[$key]);
    throw new Varien_Exception("Invalid method ".get_class($this)."::".$method."(".print_r($args,1).")");

The first case is the magic getter, next one is magic setter, then magic unsetter and finally magic has.

So in that case, the block is being assigned a brand_image_url dynamically by one of the following call:

$block->setData('brand_image_url', $foo);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.