我需要幫助,幫助我熟悉幫助者,他們的方法和產品屬性。具體做法是:$_helper->productAttribute($product, $attributeHtml, $attributeName)
需要幫助瞭解產品頁面的productAttribute()方法
下面是我使用/審查文件:
app\code\core\Mage\catalog\helper\output.php
app\design\frontend\[theme name]\template\catalog\product\view\media.phtml
下面的代碼行生成的產品圖像的HTML。
echo $_helper->productAttribute($_product, $_img, 'image');
幫助程序類代碼描述了以下幾段代碼中的方法。什麼是返回,什麼是步驟,以及爲什麼我會使用此方法而不是簡單地回顯模板文件的上一行中描述的img html?
public function getHandlers($method)
{
$method = strtolower($method);
return isset($this->_handlers[$method]) ? $this->_handlers[$method] : array();
}
public function process($method, $result, $params)
{
foreach ($this->getHandlers($method) as $handler) {
if (method_exists($handler, $method)) {
$result = $handler->$method($this, $result, $params);
}
}
return $result;
}
public function productAttribute($product, $attributeHtml, $attributeName)
{
/* Code that is not relevant to this example */
$attributeHtml = $this->process('productAttribute', $attributeHtml, array(
'product' => $product,
'attribute' => $attributeName
));
return $attributeHtml;
}
任何幫助表示讚賞。
它可能添加處理程序,並且正在執行這些處理程序。你不能調試,看看還有更多的事情發生嗎?它可能是一個抽象的方式,可能會更有用的其他元素:) – EricG
優秀的建議。我仍然在想出一個有效的方法來調試magento,並接受建議。 至於抽象的方式,這是有道理的。對於發生的事情的步驟也將不勝感激。 :) – MSD
谷歌瀏覽器有一個很好的調試器。打開檢查器(Ctrl-Shift-J)並轉到源。您可以使用Ctrl-Shift-F在其中的所有源中搜索。或者手動打開src,並放置一個斷點。然後通過它:) – EricG