我有一个名为manufacturer
的属性,其中包含我的产品品牌。喜欢:Apple Co
我的品牌图片存储在:media/wysiwyg/queldorei/shopper/brands
。名称如下:apple_co
现在我想在产品页面中展示我的品牌形象。我希望主题可以点击,然后把我带到一个包含所有这些品牌产品的页面。
我将底部代码放入:template/catalog/product/view.phtml
<?php $_product = $this->getProduct();
$manufacturerName = $_product->getAttributeText('manufacturer');
$manufacturerId = $_product->getManufacturer();
echo '<a href="/catalogsearch/advanced/result/?manufacturer[]='.$manufacturerId.'">' ?>
<img src="../media/wysiwyg/queldorei/shopper/brands/<?php echo str_replace(' ', '_',$manufacturerName); ?>.png" alt="<?php echo $manufacturerName; ?>" /></a>
它在产品页面中显示品牌,但是当我点击它时,我面对这个错误:
The requested URL /catalogsearch/advanced/result/ was not found on this server.
答案 0 :(得分:0)
使用品牌而非制造商的属性,应该有效。
<?php if($_product->getBrand()):
$brandName = $_product->getAttributeText('brand');
$brandImg = strtolower(str_replace("&","",$_product->getAttributeText('brand')));
$brandImg = str_replace(" ","-",$brandImg);
$brandImg = str_replace("--","-",$brandImg);
?>
<a href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'brands/?brand=' . urlencode($brandName) ?>">
<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'image/route/' . $brandImg . '.jpg' ?>" alt="View more" title="View more">
</a>
<?php endif; ?>