Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8629885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:55:22+00:00 2026-06-12T08:55:22+00:00

I am learning Magento and I come across this problem. Template File code <?php

  • 0

I am learning Magento and I come across this problem.

Template File code

    <?php $testimonials = $this->getTestimonials(); ?>
<?php $i = 0;?>
<?php if ($testimonials->count() > 0): ?>
<div class="block testimonials_sidebar">
    <div class="block-title">
    <strong><span><?php echo $this->__('Testimonials') ?></span></strong>
    </div>
    <div class="block-content">
        <?php foreach ($testimonials as $testimonial): ?>
            <div class="testimonial_sidebar_box">
                <div class="testimonial_sidebar_text"><?php echo $testimonial->getTestimonialText(); ?></div>
                <div class="testimonial_sidebar_name"><?php echo $testimonial->getTestimonialName(); ?></div>
            </div>
        <?php endforeach; ?>
        <div class="actions">
            <a href="<?php echo $this->getUrl('testimonials'); ?>"><?php echo $this->__('View All Testimonials'); ?></a>
        </div>
    </div>
</div>
<?php endif;?>

When I go to block to see the First line of code in the Template file which is

 <?php $testimonials = $this->getTestimonials(); ?>

And I could not find this method declared in that block class, instead I can see this method but in commented section. But This method hasn’t been declared anywhere in the module. How is this happening? Block class code below.

/**
 * Frontend block for testimonials
 *
 * @method Turnkeye_Testimonial_Model_Mysql4_Testimonial_Collection getTestimonials()
 */
class Turnkeye_Testimonial_Block_Testimonial extends Mage_Core_Block_Template
{

    /**
     * Before rendering html, but after trying to load cache
     *
     * @return Turnkeye_Testimonial_Block_Testimonial
     */
    protected function _beforeToHtml()
    {
        $this->_prepareCollection();
        return parent::_beforeToHtml();
    }

    /**
     * Prepare testimonial collection object
     *
     * @return Turnkeye_Testimonial_Block_Testimonial
     */
    protected function _prepareCollection()
    {
        /* @var $collection Turnkeye_Testimonial_Model_Mysql4_Testimonial_Collection */
        $collection = Mage::getModel("turnkeye_testimonial/testimonial")->getCollection();
        if ($this->getSidebar()){
            $collection->addFieldToFilter('testimonial_sidebar', '1');
        }

        $collection->setOrder('testimonial_position', 'ASC')
                   ->load();
        $this->setTestimonials($collection);
        return $this;
    }

}

If I am ctrl click on that method in template file it’s taking me to that method in comments. I can see it’s pointing towards collection so here is my collection code.

class Turnkeye_Testimonial_Model_Mysql4_Testimonial_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{

/**
 * Initialization here
 *
 */
public function _construct()
{
    parent::_construct();
    $this->_init('turnkeye_testimonial/testimonial');
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:55:23+00:00Added an answer on June 12, 2026 at 8:55 am

    Magento makes uses the magic __call() method to dynamically “create” accessor methods for private (hidden) data in Magento objects.

    Most classes in Magento inherit from Varien_Object, where the magic __call() method is defined.

    If you want to know more about the magic __call() function in PHP, you can read about it here: http://www.php.net/manual/en/language.oop5.overloading.php#object.call.

    Other magic methods can be found here: http://www.php.net/manual/en/language.oop5.magic.php. (Similar to __call() are the magic methods __get() and __set()).

    I found an article that gives an explanation of how this all works in Magento: http://codemagento.com/2011/02/where-are-my-getters-and-setters/.

    The comment line that you saw that starts with @method is a hint to document generators, IDEs, and to you, that while this method isn’t defined in the code, it should be accessible by the magic __call() method. If you’re using an IDE like Netbeans or Eclipse, you should get code completion for the method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently learning Magento and seem to have come across a problem that is
Learning some VBA. So far, I've constructed this piece of code which should allow
Learning C++ and see the class laid out like this: class CRectangle { int
Still learning magento coding. I wonder is there a way I can print out
Im doing a little messing around and on a learning curve with Magento, Jquery
Learning xml, Can anyone help me? I have following XML code: **<book lang=en>name of
learning Jquery and integrating with PHP - getting there, but have one last challenge
Learning C and this is an exercise. The user is asked to input the
Learning to use Ruby Threads for transportability of code between different OS platforms. The
learning about loops (still a beginner) in VB.net. I have got the below code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.