Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Show product’s category in grid/list search results
 
cibernoid
Sr. Member
 
Avatar
Total Posts:  208
Joined:  2008-02-12
 

In the Catalog grid/list view, in order to show the product name along with related category, I use this code:

<?php
if (Mage::registry('current_category'))
     
{
          
echo Mage::registry('current_category')->getName();
     
}
?>

But this doesn’t do the trick when the Catalog grid/list view shows search results (basically, category name isn’t retrieved).

Is there a way to show product’s name and category in search results?

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
cibernoid
Sr. Member
 
Avatar
Total Posts:  208
Joined:  2008-02-12
 

Can anyone help about this issue? I have tried several ways to retrieve category associated to the products but without sucess.
Searching the forum does not help either.
thanks in advanced.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Oleg Nesterov
Jr. Member
 
Total Posts:  1
Joined:  2008-07-16
 
cibernoid - 17 July 2008 03:54 AM

Can anyone help about this issue? I have tried several ways to retrieve category associated to the products but without sucess.
Searching the forum does not help either.
thanks in advanced.

Hi, try to add the next code into the ...template/catalog/product/list.html

<?php $categories $_product->getCategoryIds(); $cat_count count($categories); ?>
            <?php 
echo $cat_count $this->__('Categories:') : $this->__('Category:'?>
            <?php 
foreach($categories as $k => $_category_id): ?>
               <?php $_category 
Mage::getModel('catalog/category')->load($_category_id?>
               
<a href="<?php echo $_category->getUrl() ?>"><?php echo $_category->getName() ?></a><?php if($k != $cat_count 1): ?><?php endif; ?>
            <?php 
endforeach; ?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Mirasvit
Guru
 
Avatar
Total Posts:  639
Joined:  2009-08-22
 

It is possible that you need something like this extension Advanced Sphinx Search Pro http://mirasvit.com/magento-extensions/magento-sphinx-search.html

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top