Your shopping cart is empty. Browse our Store

Magento

Open Source eCommerce Evolved

Magento Forum

   
Search Results Grid Different From Product Grid Listing
 
katiek648
Jr. Member
 
Total Posts:  11
Joined:  2008-04-10
 

Can someone help me out here?

I customized the product listing grid here: /template/catelog/product/list.pthml

Instead of showing the description, I am showing the ShortDescription so I modified the code to look like this:

<img src="/skin/frontend/default/default/images/product-divider.gif">
 
<?php echo nl2br($_product->getShortDescription()) ?>
 
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><span class="learnMore"><?php echo $this->__('Learn More'?></span></a>

It looks great on the homepage (http://shop.ode1.deasil.com/), but when I search for something, the Short Description doesn’t show up. As far as I can tell, it is pulling from the same page (/template/catelog/product/list.pthml).
http://shop.ode1.deasil.com/catalogsearch/result/?q=oil&x;=0&y;=0

Can anyone explain to me why the ShortDescription is not showing up in my search results?

Thanks,
Katie

 
Magento Community Magento Community
Magento Community
Magento Community
 
ralphie
Jr. Member
 
Total Posts:  27
Joined:  2007-12-20
London
 

good questions.. have the same issue..

 
Magento Community Magento Community
Magento Community
Magento Community
 
dan_w
Sr. Member
 
Total Posts:  122
Joined:  2008-01-04
 

From what I can see, it doesn’t look like the Result.php block loads the short description in the _getProductCollection function. The getShortDescription will work, but you just need to tell the block to load that info so that you can call it. Open up app->core->Mage->CatalogSearch->Block->Result.php. You should see the following function:

protected function _getProductCollection()
    
{
        
if (is_null($this->_productCollection)) {
            $this
->_productCollection $this->_getQuery()->getResultCollection()
                ->
addAttributeToSelect('url_key')
                ->
addAttributeToSelect('name')
                ->
addAttributeToSelect('price')
                ->
addAttributeToSelect('special_price')
                ->
addAttributeToSelect('special_from_date')
                ->
addAttributeToSelect('special_to_date')
                ->
addAttributeToSelect('description')
                ->
addAttributeToSelect('image')
                ->
addAttributeToSelect('small_image')
                ->
addAttributeToSelect('tax_class_id');

            
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($this->_productCollection);
            
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($this->_productCollection);
        
}

        
return $this->_productCollection;
    
}

As you can see, the short_description is not part of the select query. You can change ->addAttributeToSelect(’description’) to ->addAttributeToSelect(’short_description’), or you can add ->addAttributeTo Select(’short_description’) entirely. Of course, proper conventions would say that you should ammend the function via the local code pool as to preserve the integrity of your changes across future upgrades, but this’ll give you an idea as to how to get the short_description to show up. Hope that helps.

Dan

 
Magento Community Magento Community
Magento Community
Magento Community
 
ralphie
Jr. Member
 
Total Posts:  27
Joined:  2007-12-20
London
 

hi dan

thanks for that, nice one. i guess i will change this function then. however hope that in the future this field will be added in the core, don’t see a point why not?

cheers,

ralph

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
© Copyright 2008 Varien. Magento is a trademark of Irubin Consulting Inc. DBA Varien