0

I'm new to magento, and I'm struggling with this problem. I want to add Customize Compare Product to Customer Account Page, so i created my customize block in

\template\catalog\product\compare\mycompare.phtml

and in my local.xml I add

<action method="addLink" translate="label" module="catalog">
     <name>catalog.compare.list</name>
     <path>index.php/catalog/product_compare/index/</path>
     <label>My Compare</label>
</action>

<catalog_product_compare_index>
        <label>Catalog Product Compare List</label>
        <!-- Mage_Catalog -->
        <update handle="customer_account"/>
        <reference name="my.account.wrapper">
        <block type="catalog/product_compare_list" name="catalog.compare.list" template="catalog/product/compare/mycompare.phtml"/>
        </reference>
</catalog_product_compare_index>

It's work, but that block was called 2 times. And original compare products (one with new windows when clicked) also changed it's layout! How should I do to fix it??

1
  • so you want to remove the original compare products?
    – Aboodred1
    Commented Nov 27, 2014 at 22:26

2 Answers 2

1

The Problem was because I use same path with pop-up compare product.

<path>index.php/catalog/product_compare/index/</path>

and this code

 <catalog_product_compare_index>
        <label>Catalog Product Compare List</label>
        <!-- Mage_Catalog -->
        <update handle="customer_account"/>
        <reference name="my.account.wrapper">
        <block type="catalog/product_compare_list" name="catalog.compare.list" template="catalog/product/compare/mycompare.phtml"/>
        </reference>
</catalog_product_compare_index>

change pop-up compare product layout.

So, what I do here just to create new module. Create IndexController with indexAction,

public function indexAction() {
        $this->loadLayout();
        $this->getLayout()->getBlock('head')->setTitle($this->__('My Compare'));
        $this->renderLayout(); 
}

and change some code in local.xml:

<action method="addLink" translate="label" module="mycompare">
     <name>mycompare</name>
     <path>mycompare/index</path>
     <label>My Compare</label>
</action>

<mycompare_index>
        <label>Catalog Product Compare List</label>
        <!-- Mage_Catalog -->
        <update handle="customer_account"/>
        <reference name="my.account.wrapper">
        <block type="catalog/product_compare_list" name="mycompare" as="mycompare" template="catalog/product/compare/mycompare.phtml"/>
        </reference>
</mycompare_index>
0

Since I'm not sure what you want to achieve, I will be providing 2 different solutions:

Solution 1. If you need to remove the duplication in compare products popup window and add your own custom compare products block template, then you need to implement the following in local.xml:

<catalog_product_compare_index>
        <update handle="customer_account"/>

        <reference name="content">
            <action method="unsetChild"><name>catalog.compare.list</name></action>
        </reference>            

        <reference name="my.account.wrapper">
            <block type="catalog/product_compare_list" name="catalog.compare.list" template="catalog/product/compare/mycompare.phtml"/>
        </reference>
</catalog_product_compare_index>

Solution 2. If you need to add your custom compare products template block to Customer Account Dashboard page, then you need to implement the following in local.xml:

<customer_account_index>

    <reference name="my.account.wrapper">
        <block type="catalog/product_compare_list" name="catalog.compare.list" template="catalog/product/compare/mycompare.phtml"/>
    </reference>

</customer_account_index>
3
  • @Abbodred1, thx for your answer. I found the culprit. Problem was because I use same path with pop-up compare product. I just need to create new module for my compare path.
    – elune
    Commented Nov 28, 2014 at 1:17
  • @elune then try to post the solution you end up using as the correct answer.
    – Aboodred1
    Commented Nov 28, 2014 at 1:36
  • 1
    @Abbodred1, ok. thx again :)
    – elune
    Commented Nov 28, 2014 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.