문제

저는 magento를 처음 사용하는데 이 문제로 어려움을 겪고 있습니다.고객 계정 페이지에 제품 비교 사용자 정의를 추가하고 싶어서 다음에서 사용자 정의 블록을 만들었습니다.

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

내 local.xml에 추가합니다.

<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>

작동했지만 해당 블록이 2번 호출되었습니다.그리고 원래 비교 제품(클릭하면 새 창이 열리는 제품)도 레이아웃을 변경했습니다!고치려면 어떻게 해야 하나요??

도움이 되었습니까?

해결책

문제는 팝업 비교 제품과 동일한 경로를 사용했기 때문입니다.

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

그리고 이 코드

 <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>

팝업 비교 제품 레이아웃을 변경하세요.

그래서 제가 여기서 하는 일은 단지 새로운 모듈을 생성하는 것입니다.만들다 IndexController ~와 함께 indexAction,

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

그리고 일부 코드를 변경해 보세요. 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>

다른 팁

이후로 성취하고자하는 것을 확실하지 않으므로 2 가지 솔루션을 제공 할 것입니다 :

솔루션 1. 제품 팝업 창을 비교하고 자신의 사용자 정의 비교 제품 블록 템플릿을 추가 한 다음 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>
.


솔루션 2. 사용자 정의 비교 제품 템플릿 블록을 고객 계정 대시 보드 페이지에 추가 해야하는 경우 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>
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top