Página 1 de 1

Exibir link para produtos na barra de categorias

Enviado: 23 Ago 2012, 12:18
por UntouchableS
Pessoal, meu site vai vender apenas 6 produtos diferentes, estamos otimizando e customizando o site, e gostaria de que a barra de categorias da home exibisse o link direto para os produtos, ao invés da separação de categorias. Isso é possível?

Obrigado!

Re: Exibir link para produtos na barra de categorias

Enviado: 23 Ago 2012, 21:27
por Manoel Vidal
Olá,

Sim é possível, para isso edite o arquivo header.tpl que está no diretório /catalog/view/theme/SEU_TEMA/template/common/, e localize o código abaixo:
Código: Selecionar todos
<div id="menu">
  <ul>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
      <?php if ($category['children']) { ?>
      <div>
        <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>
          <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
  </ul>
</div>
E substitua por:
Código: Selecionar todos
<div id="menu">
  <ul>
    <li><a href="http://www.sualoja.com.br/linkparaoproduto">Nome do Produto 1</a></li>
    <li><a href="http://www.sualoja.com.br/linkparaoproduto">Nome do Produto 2</a></li>
    <li><a href="http://www.sualoja.com.br/linkparaoproduto">Nome do Produto 3</a></li>
    <li><a href="http://www.sualoja.com.br/linkparaoproduto">Nome do Produto 4</a></li>
    <li><a href="http://www.sualoja.com.br/linkparaoproduto">Nome do Produto 5</a></li>
   <li><a href="http://www.sualoja.com.br/linkparaoproduto">Nome do Produto 6</a></li>
  </ul>
</div>
Salve as alterações no arquivo e faça um teste.

Espero ter ajudado. :D

Re: Exibir link para produtos na barra de categorias

Enviado: 24 Ago 2012, 12:37
por UntouchableS
Manoel, muito obrigado pela ajuda!

Surgiu um problema, os links inseridos ficam um abaixo do outro ao invés de separados lado a lado conforme a barra original. Ao mesmo tempo a linha com as categorias originais foi movida para baixo.

Outro problema foi a fonte e o tamanho, que não seguiram as caracteristicas da fonte original. Veja imagem em anexo. Como consigo resolver?

Abs,

Imagem

OBS:

Meu codigo original está em PHP (veio com o tema que eu adquiri). Abaixo o código com a modificação que fiz após sua sugestão :
Código: Selecionar todos
    <div class="menu">
<ul>
    <li><a href="http://www.sualoja.com.br/linkparaoproduto">Nome do Produto 1</a></li>
	    <li><a href="http://www.sualoja.com.br/linkparaoproduto">Nome do Produto 2</a></li>
  </ul>
      <?php 
$this->load->model('catalog/category');
$this->load->model('catalog/product');

$categories_1 = $this->model_catalog_category->getCategories(0);  											// get the categories
 
if ($categories_1) {$output = '<ul id="topnav">';}  															// if there are categories available, start off with the unordered list tag
 
foreach ($categories_1 as $category_1) {																			// for each result
	$output .= '<li>';																					// put a list item tag																// get the id of this category
	$unrewritten  = $this->url->link('product/category', 'path=' . $category_1['category_id']);								// otherwise, it will be this one
	$output .= '<a href="'.($unrewritten).'">' . $category_1['name'] . '</a>';								// finally, generate the category name and wrap its link
 
	$categories_2 = $this->model_catalog_category->getCategories($category_1['category_id']);								// if this result has a sub-list, get the set of new categories
 
	if ($categories_2) {$output .= '<ul class="children">';}												// if this is a subresult, start off with an unordered list tag
 
	foreach ($categories_2 as $category_2) {																// for each of this subresult item
		$output .= '<li>';																				// put a list item tag													// get its category
		$sub_unrewritten = $this->url->link('product/category', 'path=' . $category_1['category_id'] . '_' . $category_2['category_id']);
		$output .= '<a href="'.($sub_unrewritten).'">' . $category_2['name'] . '</a>';					// now, generate the category name and wrap its link
 		
		$categories_3 = $this->model_catalog_category->getCategories($category_2['category_id']);				// if this result has a sub-list, get the set of new categories
 
		if ($categories_3) {$output .= '<ul class="children2">';}									// if this is a subresult, start off with an unordered list tag
 
		foreach ($categories_3 as $category_3) {												// for each of this third level item
			$output .= '<li>';																			// give it an opening list tag											// get its category
			$third_sub_unrewritten = $this->url->link('product/category', 'path=' . $category_1['category_id'] . '_' . $category_2['category_id'] . '_' . $category_3['category_id']);								// if its enabled, this will be the path
			$output .= '<a href="'.($third_sub_unrewritten).'">'.$category_3['name'].'</a>';		// call the category name and wrap with its link
			$output .= '</li>';																			// now close this list item
		}
 
		if ($categories_3) {$output .= '</ul>';}													// if this was the third list, clost the list
			$output .= '</li>';																			// then or otherwise, close the second level list tag
	}
	if ($categories_2) {$output .= '</ul>';}																// if all sub results have been listed, close the second level
		$output .= '</li>';																				// then or otherwise close first list parent
}
if ($categories_1) {$output .= '</ul>';}																		// then close the first level list table
echo $output; 																							// now produce the results
?>
    </div>