Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
1  
get_class($this) – Nickool 3 hours ago

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:

get_class($this);

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->setBrandImageUrl($foo);
$block->setData('brand_image_url', $foo);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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