Magento를 배우고 있는데이 문제가 발생했습니다.Magento는이 주석 처리 된 메서드를 어떻게 호출합니까?
템플릿 파일의 코드
<?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;?>
내가
<?php $testimonials = $this->getTestimonials(); ?>
있는 템플릿 파일에 코드의 첫 번째 줄을 볼 차단에 가서 내가 그 블록에서 선언이 방법을 찾을 수 없습니다 클래스 대신이 메서드를 볼 수 있지만 주석 처리 된 섹션에서 볼 수 있습니다. 그러나이 방법은 모듈의 어디에도 선언되어 있지 않습니다. 어떻게 된 일인가? 아래의 클래스 코드를 차단하십시오.
/**
* 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;
}
}
템플릿 파일에서 해당 방법을 Ctrl 키를 누른 상태로 클릭하면 주석이 표시됩니다. 콜렉션을 가리키고있는 것을 볼 수 있습니다. 콜렉션 코드는 여기에 있습니다.
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');
}
}