1

I've created attributes that I use successfully in the layered navigation of Magento.

Those attributes get output in the additional data section of the product page, however, attributes used in layered navigation don't appear as links. They're in plain text.

Simple example, I sell CDs, I have an artist attribute. I want to be able to click on the artist name, from the product page additional data section, to access the layered navigation results page that displays CDs only where this artist appears. Logic from a user point of view.

In other words, I want to get the layered navigation link from an attribute, in the product page.

Here’s what I find in catalog/product/view/attributes.html:

<?php foreach ($_additional as $_data): ?>
    <?php echo $this->htmlEscape($this->__($_data['label'])) ?>
    <?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?>
<?php endforeach; ?>

And here's the layered navigation loop:

<?php foreach ($this->getItems() as $_item): ?>

    <?php if ($_item->getCount() > 0): ?>
    <a href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>
    <?php else: echo $_item->getLabel() ?>
    <?php endif; ?>

<?php endforeach ?>

Thanks much for your help.

4

1 回答 1

1

如果您输入艺术家姓名作为文本,您可以轻松地将其与目录/产品/视图/attributes.html 中的高级搜索集成:

<?php if ($_data['label'] == "Artist"): ?>
<a href="/catalogsearch/advanced/result/?artist=<?php echo $_data['value']; ?>">
<?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></a>
<?php else: ?>
<?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?>
<?php endif; ?>

让我知道这是否是您的意思:)

编辑:也不是说此方法仅在您启用属性以用于高级搜索时才有效。

于 2011-05-22T13:29:27.417 回答