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

Add To Compare from advanced search results redirect problem
 
asmedberg
Jr. Member
 
Total Posts:  1
Joined:  2011-08-29
 

If I do an advanced search and try to “Add to Compare” on one of the products in the results, I get redirected back to the advanced search form with the message “Please specify at least one search term.” Product does get added to compare list though but same thing happens if I try to remove a product from the list on the search results page. Add to compare works everywhere else on the site.

Any suggestions on how to get the this figured out on the advanced search results pages?

 
Magento Community Magento Community
Magento Community
Magento Community
 
muk_t
Sr. Member
 
Total Posts:  226
Joined:  2012-07-24
 

Facing same problem but no solution found

 
Magento Community Magento Community
Magento Community
Magento Community
 
iiijjjiii
Jr. Member
 
Total Posts:  10
Joined:  2010-09-07
 

I am seeing the same issue. I dug into a bit and discovered the problem is the return url is getting escaped. The return url from the compare addAction takes the form:

/catalogsearch/advanced/?___SID=U&\&#x3B;attribute_one=&\&#x3B;attribute_two=...
It should be
/catalogsearch/advanced/?___SID=U&attributeone;=&attributetwo;=...
I can fix the problem by commenting out this line
app/code/core/Mage/Core/Controller/Varien/Action.php
protected function _getRefererUrl()
{
...
# $refererUrl = Mage::helper('core')->escapeUrl($refererUrl);
...
}

This isn’t an ideal solution though since that is a general function and I assume the escapeUrl() call is desirable in some cases.

I’m not sure what the ideal solution is. I am going to work on a hack where I check to see if the referer url is advanced search and if so don’t escape it.

I posted this comment here as well
http://www.magentocommerce.com/bug-tracking/issue/?issue=14415

 
Magento Community Magento Community
Magento Community
Magento Community
 
muk_t
Sr. Member
 
Total Posts:  226
Joined:  2012-07-24
 

@iiijjjiii

The changes that you describes are safe to be done?
Will there be any problem because of this in other functionality of Magento?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
iiijjjiii
Jr. Member
 
Total Posts:  10
Joined:  2010-09-07
 

No, I don’t recommend commenting out that line. I included it to illustrate that the escaping of the url was the cause of the problem.

 
Magento Community Magento Community
Magento Community
Magento Community
 
muk_t
Sr. Member
 
Total Posts:  226
Joined:  2012-07-24
 

@iiijjjiii
Thanks

I am facing this issue on one of my clients project.
I was looking for some solution for this.

 
Magento Community Magento Community
Magento Community
Magento Community
 
iiijjjiii
Jr. Member
 
Total Posts:  10
Joined:  2010-09-07
 

I was able to fix this by overloading the Mage_Catalog_Product_CompareController controller. Instructions for overloading a controller can be found in the wiki: How to overload a controller

My overloaded function looks like this:

require_once('Mage/Catalog/controllers/Product/CompareController.php');
class 
MyNameSpace_MyModule_Product_CompareController extends Mage_Catalog_Product_CompareController
{
    
public function addAction()
    
{
        parent
::addAction();
        
$refererUrl $this->_getRefererUrl();
        if (
strpos($refererUrl'catalogsearch/advanced/result')) {
            $this
->getResponse()->setRedirect(htmlspecialchars_decode($refererUrl));
        
}
    }

    
public function removeAction()
    
{
        parent
::removeAction();
        if (!
$this->getRequest()->getParam('isAjax'false)) {
            $refererUrl 
$this->_getRefererUrl();
            if (
strpos($refererUrl'catalogsearch/advanced/result')) {
                $this
->getResponse()->setRedirect(htmlspecialchars_decode($refererUrl));
            
}
        }
    }

    
public function clearAction()
    
{
        parent
::clearAction();
        
$refererUrl $this->_getRefererUrl();
        if (
strpos($refererUrl'catalogsearch/advanced/result')) {
            $this
->getResponse()->setRedirect(htmlspecialchars_decode($refererUrl));
        
}
    }
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
muk_t
Sr. Member
 
Total Posts:  226
Joined:  2012-07-24
 

@iiijjjiii

Could you please send some more details about config.xml for this

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
iiijjjiii
Jr. Member
 
Total Posts:  10
Joined:  2010-09-07
 

Something like this in app/code/local/MyNameSpace/MyModule/etc/config.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
MyNameSpace_MyModule>
            <
version>0.1.0</version>
        </
MyNameSpace_MyModule>
    </
modules>
    <
frontend>
        <
routers>
            <
catalog>
                <
args>
                    <
modules>
                        <
MyNameSpace_MyModule before="Mage_Catalog">MyNameSpace_MyModule</MyNameSpace_MyModule>
                    </
modules>
                </
args>
            </
catalog>
        </
routers>
    </
frontend>
</
config>
 
Magento Community Magento Community
Magento Community
Magento Community
 
muk_t
Sr. Member
 
Total Posts:  226
Joined:  2012-07-24
 

@iiijjjiii

Hi iiijjjiii

I am using following code but this is not working for me.
I am attaching the files here.

1)location of Advancedsearch_Advancedsearch is:
\wamp\www\magentocustmod\app\etc\modules\Advancedsearch_Advancedsearch.xml

2) location of config.xml
wamp\www\magentocustmod\app\code\local\Advancedsearch\Advancedsearch\etc\config.xml

3)location of Controller is
\www\magentocustmod\app\code\local\Advancedsearch\Advancedsearch\controllers\CompareController.php

Could you please help me.

One more question please, Can we add out of stock products as Add to compare

Thanks you

File Attachments
Advancedsearch_Advancedsearch.xml  (File Size: 1KB - Downloads: 23)
config.xml  (File Size: 1KB - Downloads: 14)
 
Magento Community Magento Community
Magento Community
Magento Community
 
iiijjjiii
Jr. Member
 
Total Posts:  10
Joined:  2010-09-07
 

Is your module enabled? Check in the back end.

System > Configuration > ADVANCED Advanced

You should see your module there. Make sure it is set to Enabled

 
Magento Community Magento Community
Magento Community
Magento Community
 
muk_t
Sr. Member
 
Total Posts:  226
Joined:  2012-07-24
 

.Thanks I found the problem,it worked for me.I created the directory structure properly,then it was working fine.
You are genius.

 
Magento Community Magento Community
Magento Community
Magento Community
 
iiijjjiii
Jr. Member
 
Total Posts:  10
Joined:  2010-09-07
 

Great to hear you got it working.

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