So, basically, I have a template that makes the following call.

$methods = $this->getMethods();
$oneMethod = count($methods) <= 1;

The corresponding block class simply has something like this

public function getMethods(){
    $methods = $this->getData('methods'); 

(I have only copied the relevant portion of the code)

The problem is that I cannot figure out where the getData is looking because no model has been instantiated in this block class or the one that extends to it. There is no call like Mage::getModel(?/?).

How does this know which table to look at in the database? The variables I'm trying to find are "payment methods" (like credit card, cheque, etc). the Block classes I'm dealing with are:

  • Mage_Payment_Block_Form_Container
  • Mage_Core_Block_Template
  • Mage_Core_Block_Abstract

No models are instantiated in any of these classes and I cannot understand how the system is returning types of payment methods for $this->getData('methods');

  • You should check the method again and update your question - what you have there is not valid PHP. Nov 18, 2015 at 17:32
  • Something, probably the controller, is setting this onto the block by $block->setMethods(...) or $block->setData('methods', ...). The block itself is not handling this.
    – 7ochem
    Nov 18, 2015 at 19:43

1 Answer 1


In app/code/core/Mage/Payment/Block/Form/Container.php there is the following;

 * Retrieve available payment methods
 * @return array
public function getMethods()
    $methods = $this->getData('methods');
    if ($methods === null) {
        $quote = $this->getQuote();
        $store = $quote ? $quote->getStoreId() : null;
        $methods = array();
        foreach ($this->helper('payment')->getStoreMethods($store, $quote) as $method) {
            if ($this->_canUseMethod($method) && $method->isApplicableToQuote(
            )) {
                $methods[] = $method;
        $this->setData('methods', $methods);
    return $methods;

You can try poking around here.

  • This is what im talking about. The first line of the function says $methods = $this->getData('methods'); What model is it looking into? if it said X = getModel(z/z); and then x->getMethods or something along those lines i would have known where to look in my database tables by looking at the config. However, here it simply says $this->getMethods how do i know which model or db table its pointing to.
    – gagan
    Nov 19, 2015 at 7:41
  • 1
    It shows you right in that method function. If $methods = null do the code in the block. foreach $this->helper('payment')->getStoreMethods($store, $quote) as $method If method can be used then $this->_assignMethod($method); $methods[] = $method; Then when the foreach is complete $this->setData('methods', $methods); Basically when that method function is called the first time, getData('methods') will return null, which is why they overloaded the getMethods method in the first place. It then will instantiate the 'methods' data, so the next time getMethods is called, it exists. Nov 19, 2015 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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