Advertisement
Guest User

brands.phtml

a guest
Oct 16th, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.52 KB | None | 0 0
  1. <?php
  2. /**
  3.  *
  4.  */
  5. ?>
  6.  
  7. <?php $helper = Mage::helper('brands'); ?>
  8.  
  9. <?php if($helper->getCfgGeneral('product_view_enabled')): ?>
  10.     <?php $_product = $this->getCurrentProductObject();?>
  11.     <?php $manufAttrId = $helper->getCfgGeneral('attr_id'); ?>
  12.     <?php if ($_product->getData($manufAttrId)): //If manufacturer/brand attribute exists ?>
  13.  
  14.         <?php
  15.         $manufImageExt = trim($helper->getCfgGeneral('image_extension'));
  16.         $manufLinkSearch = $helper->getCfgGeneral('link_search_enabled'); //If true, brand logo is link to Quick Search results
  17.         $manufPageBasePath = trim($helper->getCfgGeneral('page_base_path')); //Base path of each brand's page
  18.         $attr = $_product->getResource()->getAttribute($manufAttrId); //Attr. object
  19.         $manufValue = trim($attr->getFrontend()->getValue($_product)); //Attr. value
  20.         $manufValueCode = str_replace(" ", "_", strtolower($manufValue)); //Attr. value (simplified)
  21.         $manufLabel = $attr->getStoreLabel(); //Attr. label
  22.         //$manufLabelCode = str_replace(" ", "-", strtolower($manufLabel)); //Attr. label (simplified)
  23.         $manufImageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'v1/attributes/' . $manufAttrId . '/' . $manufValueCode . '.' . $manufImageExt;
  24.  
  25.         if ($manufLinkSearch)
  26.             $manufPageUrl = Mage::getUrl() . 'catalogsearch/result/?q=' . $manufValue;
  27.         elseif ($manufPageBasePath != '')
  28.         {
  29.             //If $manufPageBasePath is '/', then '/' has to be omitted
  30.             //Change brand name to lowercase, and replace spaces with hyphens
  31.             $basePath = ($manufPageBasePath == '/') ? '' : $manufPageBasePath . '/';
  32.             $manufPageUrl = Mage::getUrl() . $basePath . str_replace(" ", "-", strtolower($manufValue));
  33.            
  34.             //Append category URL suffix if needed and if it exists
  35.             if ($helper->getCfgGeneral('append_category_suffix'))
  36.                 $manufPageUrl .= Mage::getStoreConfig('catalog/seo/category_url_suffix');
  37.         }
  38.         else
  39.             $manufPageUrl = '';
  40.  
  41.         //if (file_exists($manufImageUrl) == FALSE)
  42.         //  $manufImageUrl = $this->getSkinUrl("images/img/brand-placeholder.png");
  43.         ?>
  44.         <div class="box-brand">
  45.             <?php if ($manufPageUrl != ''): ?>
  46.                 <a href="<?php echo $manufPageUrl;?>" title="<?php echo str_replace("%s", $manufValue, $this->__('Click to see more products from %s')); ?>"><img src="<?php echo $manufImageUrl;?>" alt="<?php echo $manufValue; ?>" width="90" /></a>
  47.             <?php else: ?>
  48.                 <img src="<?php echo $manufImageUrl;?>" title="<?php echo $manufLabel .': '. $manufValue; ?>" alt="<?php echo $manufValue; ?>" width="90" />
  49.             <?php endif; ?>
  50.         </div>
  51.  
  52.     <?php endif; ?>
  53. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement