ためproductAttribute()メソッドを理解するヘルプ、および製品の属性。具体的に:次のコード行は、商品画像のHTMLを生成は製品ページ
app\code\core\Mage\catalog\helper\output.php
app\design\frontend\[theme name]\template\catalog\product\view\media.phtml
:ここ$_helper->productAttribute($product, $attributeHtml, $attributeName)
は、私は/見直しを使用していたファイルです。
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
Google Chromeには優れたデバッガがあります。インスペクタ(Ctrl-Shift-J)を開き、「ソース」に移動します。 Ctrl-Shift-Fを使用して、すべてのソースを検索することができます。または、srcを手動で開き、ブレークポイントを設定します。それからステップしてください:) – EricG