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

Change compare products to open not in a pop-up window
 
Claudio Vargas
Jr. Member
 
Total Posts:  22
Joined:  2007-12-23
 

I think the compare products feature is fantastic, so my question is how can I configure it to open not in a pop-up window and just have it open in a regular page within the content block?

I found this on line 36 in app\design\frontend\default\default\template\catalog\product\compare\sidebar.phtml, which I think is what activates the pop-up (I mmay be wrong), so how can I disable the pop-up feature?

<div class="actions">
<a href="<?=$this->helper('catalog/product_compare')->getClearListUrl()?>" class="left"><?=$this->__('Eliminar todos')?></a>
<button class="form-button-alt" onclick="popWin(’<?=$this->helper('catalog/product_compare')->getListUrl()?>’,’compare’,’width=800,height=600,resizable=yes,scrollbars=yes’)"><span><?=$this->__('Comparar')?></span></button>
</div>

 
Magento Community Magento Community
Magento Community
Magento Community
 
_
Sr. Member
 
Total Posts:  152
Joined:  2007-08-31
 

You should change

<div class="actions">
            <
a href="<?=$this->helper('catalog/product_compare')->getClearListUrl()?>" class="left"><?=$this->__('Clear All Items')?></a>
            <
button class="form-button-alt" onclick="popWin('<?=$this->helper('catalog/product_compare')->getListUrl()?>','compare','width=800,height=600,resizable=yes,scrollbars=yes')"><span><?=$this->__('Compare Items')?></span></button>
        </
div>

into this

<div class="actions">
            <
a href="<?=$this->helper('catalog/product_compare')->getClearListUrl()?>" class="left"><?=$this->__('Clear All Items')?></a>
            <
a href="<?=$this->helper('catalog/product_compare')->getListUrl()?>"><span><?=$this->__('Compare Items')?></span></a>
        </
div>

but wihout changes in layout xml files you’ll only see a normal page without columns. To append changes to layout xml file please

1. open catalog.xml in layouts folder
2. search for

<reference name="root">
            <
action method="setTemplate"><template>page/one-column.phtml</template></action>
        </
reference>

3. replace with

<reference name="root">
            <
action method="setTemplate"><template>page/2columns-right.phtml</template></action>
        </
reference>

in section beggining with

<!--
Compare products page
-->

so that the code looks like below

<catalog_product_compare_index>
        <!-- 
Mage_Catalog -->
        <
reference name="root">
            <
action method="setTemplate"><template>page/2columns-right.phtml</template></action>
        </
reference>
        <
reference name="head">
            <
action method="addJs"><script>scriptaculous/scriptaculous.js</script></action>
            <
action method="addJs"><script>varien/product.js</script></action>
        </
reference>
        <
reference name="content">
            <
block type="catalog/product_compare_list" name="catalog.compare.list" template="catalog/product/compare/list.phtml"/>
        </
reference>
    </
catalog_product_compare_index>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Claudio Vargas
Jr. Member
 
Total Posts:  22
Joined:  2007-12-23
 

Awesome!! Thanks a lot for your help, it works excellent!!

I think one more important modification that could be made would be to remove the print this page line and also the close this window button because since now the compared products are being opened inside the content box they aren´t really necessary in my perspective, so anyway, after looking at the code a bit I found the following lines that could be changed (all this on list.phtml)

to remove print this page line delete on line 23:

<a href="#" class="link-print right" onclick="print();"><?=$this->__('Print This Page')?></a>

to remove close window button delete on lines 111-113:

<div class="button-set">
        <
button class="form-button" onclick="window.close();window.opener.focus();"><span><?=$this->__('Close Window')?></span></button>
    </
div>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Claudio Vargas
Jr. Member
 
Total Posts:  22
Joined:  2007-12-23
 

It works but I can´t go back to te catalog or to an individual product page when I click them in the compared products list. Do you know what could be done to fix this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
thugsb
Member
 
Avatar
Total Posts:  50
Joined:  2009-09-08
UK
 

You need to change them into direct links (replace the <a href="#" and remove the onclick):

<td>
                    <
a href="<?php echo $_item->getProductUrl() ?>"  title="<?php echo $this->htmlEscape($_item->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(125, 125); ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" /></a>
                    <
h3 class="zero-margin"><a href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_item->getName()) ?>"><?php echo $this->htmlEscape($_item->getName()) ?></a></h3>

Hope that helps (in list.phtml, around line 55 ish)

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