This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I am developing a custom product page for our store and I need help familiarizing myself with helpers, their methods, and product attributes. Specifically: $_helper->productAttribute($product, $attributeHtml, $attributeName)
Here are the files I am using/reviewing: app\code\core\Mage\catalog\helper\output.php app\design\frontend[theme name]\template\catalog\product\view\media.phtml
My first goal in customizing the page is to edit the width of the product image. The following line of code generates the html for the product image.
echo $_helper->productAttribute($_product, $_img, 'image');
Why do we need this method if we can simply echo the img html described in the previous line?
What exactly is being returned and why I would use this method? The following pieces of code are what I'd like to understand the most and if someone could explain it to me, I'd greatly appreciate it.
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;
}
Thank you for any help. [Edited to be concise]
Subreddit
Post Details
- Posted
- 11 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/Magento/com...