How to display simple product descriptions on a grouped product page?
문제
When working with a grouped product on Magento (such as a furniture set), very little info is displayed by default about its simple products.
The demo site example doesn't appear to allow the user to explore any detail of the simples' dimensions or other attributes. All it shows are the names and prices.
Are there any template methods available on a grouped product page to display more detailed data about its component simple products? Things like short descriptions, thumbnails, URLs to simple product view (if active), etc.
해결책
In catalog/product/view/type/grouped.phtml
you can find a table #super-product-table
that contains the basic information you mentioned for associated products. To add a short description (for example) you should add something like this inside the body of the table, in other words inside foreach ($_associatedProducts as $_item)
loop:
<?php echo $this->htmlEscape($_item->getShortDescription()) ?>
다른 팁
Let's say in catalog/product/view.phtml
you can do something like this:
if($_product->isGrouped()) {
$_associatedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product);
foreach($_associatedProducts as $_associatedProduct) {
if($_description = $_associatedProduct->getShortDescription()) {
echo $this->helper('catalog/output')->productAttribute($_associatedProduct, $_description, 'short_description');
}
}
}