Need help buying now? +48-22-219-5163 +1-917-720-3250
My Cart

Your Cart is Empty

Need help buying now?
+48-22-219-5163 +1-917-720-3250

The category and products configuration

The category and products configuration

Magento frontend is often changed based on the personal preferences or usability testing. Let us review how to make a tree-categories and how to remove the comparison of the products.

Tree-categories of the menu

Before you start, you need to choose the block which we will output as a tree. For example, let’s take catalog/navigation/left.phtml. The code has been taken from the site http://gurumagento.varshevsky.com and created with the class called Varien_Data_Tree:

<div id="leftnav"><br>
	<?php $helper = $this->helper('catalog/category') ?><br>
	<?php $categories = $this->getStoreCategories() ?><br>
	<?php if (count($categories) > 0): ?><br>
   	<ul id="leftnav-tree" class="level0"><br>
       	<?php foreach($categories as $category): ?><br>
           	<li class="level0<?php if ($this->isCategoryActive($category)): ?> 
            active<?php endif; ?>"><br>
               	<a href="<?php echo $helper->getCategoryUrl($category) ?>"><span>
                <?php echo $this->escapeHtml($category->getName()) ?></span></a><br>
               	<?php if ($this->isCategoryActive($category)): ?><br>
                   	<?php $subcategories = $category->getChildren() ?><br>
                   	<?php if (count($subcategories) > 0): ?><br>
            	           <ul id="leftnav-tree-<?php echo $category->getId() ?>" 
                         class="level1"><br>
                           	<?php foreach($subcategories as $subcategory): ?><br>
                               	<li class="level1<?php if ($this->isCategoryActive
                                ($subcategory)): ?> active<?php endif; ?>"><br>
                                   	<a href="<?php echo $helper->getCategoryUrl
                                    ($subcategory) ?>"><?php echo $this->escapeHtml(
                                    trim($subcategory->getName(), '- ')) ?></a><br>
                      	         </li><br>
                           	<?php endforeach; ?><br>
                           </ul><br>
                       	<script type="text/javascript">decorateList('leftnav-tree-
                        <?php echo $category->getId() ?>', 'recursive')</script><br>
                   	<?php endif; ?><br>
               	<?php endif; ?><br>
           	</li><br>
       	<?php endforeach; ?><br>
   	</ul><br>
   	<script type="text/javascript">decorateList('leftnav-tree', 'recursive')</script><br>
	<?php endif; ?><br>
</div>

 

This code allows outputting all the subcategories which are located in this category with the so-called tree. It is very comfortable when you need to look through all the department titles at once. Also it looks like more original than the standard dropdown menu.

How to disable the products comparison

Customers do not always need to see similar items, especially if it is not provided by the theme of your online store. If you want to remove the products comparison, you need to do the following:

Go to app -> design and then you should go to frontend/deafult/Your_Theme/layout/reports.xml.

You need to remove the following code in this file:

<block type="reports/product_compared" before="right.permanent.callout" 
name="right.reports.product.compared" template="reports/product_compared.phtml" />

 

You need to open the file called catalog.xml in the same layout folder and remove the following code:

<block type="core/template" before="cart_sidebar" name="catalog.compare.sidebar" 
template="catalog/product/compare/sidebar.phtml"/>

 

You need to follow the next path in the folder with the theme of your Magento store: /template/catalog/product/view, and delete the following code in the file addto.phtml:

<?php if($_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product) ): ?>
<li><span class="pipe">|</span> <a href="<?php echo 
$_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>

 

Let’s go to the Product folder and find the file list.phtml. You need to erase the following code in this file:

<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
	<li><span class="separator">|</span> <a rel="nofollow" href="<?php echo 
  $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>

 

Please be careful because this code is located in two places and you should remove it from both.

You should find the following in the folder with the theme template => reports => home_product_viewed.phtml and remove the following:

 
<?php if ($_compareUrl = $this->getAddToCompareUrl($_product)): ?>
 	<li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" 
  class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>

 

The described code has been taken from the site gurumagento.varshevsky.com

You should do the backup of your Magento store database and disable the cache before you start working. After doing these actions please do not forget to enable the cache and check the work of the done changes. If you have any issues with the changing of the categories view or the products in Magento store, you can contact GoMage specialists and they will help you. Also you can leave your comments in this article as to how to change the frontend and the admin panel of the Magento site.

Newsletter