製品ごとに、特定のカテゴリのメンバーであるかどうかを確認し、連想配列のリストに基づいて属性を確認して表示できます。このようなもの:
$_productsCollection = $this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
$cats = array( // keys are category IDs
1 => array('processor', 'disk', 'ram'), // attribute codes
2 => array('screen', 'weight', 'battery')
);
// loop product collection in widget
foreach ($_productsCollection as $_product) {
// loop array of categories
foreach ($cat as $cat_id => $attributes) {
// loop array of attributes if the product is in this category
if (in_array($cat_id, $_product->getAvailableInCategories())) {
foreach ($attributes as $attribute) {
if ($attr = $_product->getData($attribute)) {
$resource = $_product->getResource();
// markup and $helper to display image here
echo $resource->getAttribute($attribute)->getStoreLabel().': '.$attr;
// markup and getProductUrl() here, etc.
}
}
}
}
}
これはテストされていませんが、アイデアが得られるかもしれません。製品がリスト内の複数のカテゴリのメンバーである可能性がある場合を処理するには、いくつかのコードを追加する必要があります。