2011-08-15 3 views
1

必要なもの: "コンテンツ"ではなく "右側の"セクションの "addtocart"ブロックと "product_type_data"ブロックMagento - "product.info"ブロックをサイドバーにクローン化し、条件付き製品タイプのデータを含める

私が試したこと:sidebar.phtmlと呼ばれるブロック用の新しいファイルを作成して、これを私のテーマの内側にあるlocal.xmlに挿入しようとしました(.xmlファイルは他のブロックでうまく機能します)

<default> 

     <reference name="right"> 
      <action method="unsetChildren"></action><!-- remove all blocks --> 

      <block type="catalog/product_view" name="product.sidebar" template="catalog/product/view/sidebar.phtml"> 

       <block type="catalog/product_view" name="product.sidebar.options.wrapper" as="product_options_wrapper" template="catalog/product/view/options/wrapper.phtml" translate="label"> 
        <label>Info Column Options Wrapper</label> 
        <block type="core/template" name="options_js" template="catalog/product/view/options/js.phtml"/> 
        <block type="catalog/product_view_options" name="product.sidebar.options" as="product_options" template="catalog/product/view/options.phtml"> 
         <action method="addOptionRenderer"><type>text</type><block>catalog/product_view_options_type_text</block><template>catalog/product/view/options/type/text.phtml</template></action> 
         <action method="addOptionRenderer"><type>file</type><block>catalog/product_view_options_type_file</block><template>catalog/product/view/options/type/file.phtml</template></action> 
         <action method="addOptionRenderer"><type>select</type><block>catalog/product_view_options_type_select</block><template>catalog/product/view/options/type/select.phtml</template></action> 
         <action method="addOptionRenderer"><type>date</type><block>catalog/product_view_options_type_date</block><template>catalog/product/view/options/type/date.phtml</template></action> 
       </block> 
         <block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/> 
        </block> 
       <block type="catalog/product_view" name="product.sidebar.options.wrapper.bottom" as="product_options_wrapper_bottom" template="catalog/product/view/options/wrapper/bottom.phtml" translate="label"> 
        <label>Bottom Block Options Wrapper</label> 
        <action method="insert"><block>product.tierprices</block></action> 
        <block type="catalog/product_view" name="product.clone_prices" as="prices" template="catalog/product/view/price_clone.phtml"/> 
        <action method="append"><block>product.sidebar.addtocart</block></action> 
        <action method="append"><block>product.sidebar.addto</block></action> 
       </block> 

       <block type="core/template_facade" name="product.sidebar.container1" as="container1"> 
        <action method="setDataByKey"><key>alias_in_layout</key><value>container1</value></action> 
        <action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action> 
        <action method="append"><block>product.sidebar.options.wrapper</block></action> 
        <action method="append"><block>product.sidebar.options.wrapper.bottom</block></action> 
       </block> 
       <block type="core/template_facade" name="product.sidebar.container2" as="container2"> 
        <action method="setDataByKey"><key>alias_in_layout</key><value>container2</value></action> 
        <action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action> 
        <action method="append"><block>product.sidebar.options.wrapper</block></action> 
        <action method="append"><block>product.sidebar.options.wrapper.bottom</block></action> 
       </block> 
       <action method="unsetCallChild"><child>container1</child><call>ifEquals</call><if>0</if><key>alias_in_layout</key><key>options_container</key></action> 
       <action method="unsetCallChild"><child>container2</child><call>ifEquals</call><if>0</if><key>alias_in_layout</key><key>options_container</key></action> 

      </block> 

     </reference> 


    </default> 

<!-- 
    Additional block dependant on product type 
    --> 
    <PRODUCT_TYPE_simple translate="label" module="catalog"> 
     <label>Catalog Product View (Simple)</label> 
     <reference name="product.sidebar"> 
      <block type="catalog/product_view_type_simple" name="product.info.simple" as="product_type_data" template="catalog/product/view/type/default.phtml"> 
       <block type="core/text_list" name="product.info.simple.extra" as="product_type_data_extra" translate="label"> 
        <label>Product Extra Info</label> 
       </block> 
      </block> 
     </reference> 
    </PRODUCT_TYPE_simple> 
    <PRODUCT_TYPE_configurable translate="label" module="catalog"> 
     <label>Catalog Product View (Configurable)</label> 
     <reference name="product.sidebar"> 
      <block type="catalog/product_view_type_configurable" name="product.info.configurable" as="product_type_data" template="catalog/product/view/type/default.phtml"> 
       <block type="core/text_list" name="product.info.configurable.extra" as="product_type_data_extra" translate="label"> 
        <label>Product Extra Info</label> 
       </block> 
      </block> 
     </reference> 
     <reference name="product.sidebar.options.wrapper"> 
      <block type="catalog/product_view_type_configurable" name="product.info.options.configurable" as="options_configurable" before="-" template="catalog/product/view/type/options/configurable.phtml"/> 
     </reference> 
    </PRODUCT_TYPE_configurable> 
    <PRODUCT_TYPE_grouped translate="label" module="catalog"> 
     <label>Catalog Product View (Grouped)</label> 
     <reference name="product.sidebar"> 
      <block type="catalog/product_view_type_grouped" name="product.info.grouped" as="product_type_data" template="catalog/product/view/type/grouped.phtml"> 
       <block type="core/text_list" name="product.info.grouped.extra" as="product_type_data_extra" translate="label"> 
        <label>Product Extra Info</label> 
       </block> 
      </block> 
     </reference> 
    </PRODUCT_TYPE_grouped> 
    <PRODUCT_TYPE_virtual translate="label" module="catalog"> 
     <label>Catalog Product View (Virtual)</label> 
     <reference name="product.sidebar"> 
      <block type="catalog/product_view_type_virtual" name="product.info.virtual" as="product_type_data" template="catalog/product/view/type/default.phtml"> 
       <block type="core/text_list" name="product.info.virtual.extra" as="product_type_data_extra" translate="label"> 
        <label>Product Extra Info</label> 
       </block> 
      </block> 
     </reference> 
    </PRODUCT_TYPE_virtual> 

これがある程度機能し、それは私のサイドバーに「addtocart」ブロックとオプションラッパーなどが追加されますが、その中に「product_type_data」ブロックを追加doesntの、私はfeeliをしました

<?php $_helper = $this->helper('catalog/output'); ?> 
<?php $_product = $this->getProduct(); ?> 

    <!-- Product Type Options Start --> 
      <?php echo $this->getChildHtml('product_type_data') ?> 
     <!-- Product Type Options End --> 

     <?php echo $this->getTierPriceHtml() ?> 

     <!-- container1 --> 
     <?php if ($_product->isSaleable() && $this->hasOptions()):?> 
      <?php echo $this->getChildChildHtml('container1', '', true, true) ?> 
     <?php endif;?> 

     <!-- container2 --> 
     <?php if ($_product->isSaleable() && $this->hasOptions()):?> 
      <?php echo $this->getChildChildHtml('container2', '', true, true) ?> 
     <?php endif;?> 

すべてのヘルプは大規模な参考になる:NG

また、私sidebar.phtmlファイルは次のようになります...が、これらの条件タグで間違ったものになるが、私のXMLの知識は非常に限られていることがあります。

<reference name="right"> 
       <block type="catalog/product_view" name="product.info.options.wrapper" as="product_options_wrapper" template="catalog/product/view/options/wrapper.phtml" translate="label"> 
       <label>Info Column Options Wrapper</label> 
       <block type="core/template" name="options_js" template="catalog/product/view/options/js.phtml"/> 
       <block type="catalog/product_view_options" name="product.info.options" as="product_options" template="catalog/product/view/options.phtml"> 
        <action method="addOptionRenderer"><type>text</type><block>catalog/product_view_options_type_text</block><template>catalog/product/view/options/type/text.phtml</template></action> 
        <action method="addOptionRenderer"><type>file</type><block>catalog/product_view_options_type_file</block><template>catalog/product/view/options/type/file.phtml</template></action> 
        <action method="addOptionRenderer"><type>select</type><block>catalog/product_view_options_type_select</block><template>catalog/product/view/options/type/select.phtml</template></action> 
        <action method="addOptionRenderer"><type>date</type><block>catalog/product_view_options_type_date</block><template>catalog/product/view/options/type/date.phtml</template></action> 
      </block> 
        <block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/> 
       </block> 
      <block type="catalog/product_view" name="product.info.options.wrapper.bottom" as="product_options_wrapper_bottom" template="catalog/product/view/options/wrapper/bottom.phtml" translate="label"> 
       <label>Bottom Block Options Wrapper</label> 
       <action method="insert"><block>product.tierprices</block></action> 
       <block type="catalog/product_view" name="product.clone_prices" as="prices" template="catalog/product/view/price_clone.phtml"/> 
       <action method="append"><block>product.info.addtocart</block></action> 
       <action method="append"><block>product.info.addto</block></action> 
      </block> 



     <block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/> 
    </reference> 

:次に、このようになります

感謝、デイブ

答えて

1

ゴーのcatalog.xmlすると

<block type="catalog/product_view" name="product.info.options.wrapper" as="product_options_wrapper" template="catalog/product/view/options/wrapper.phtml" translate="label"> 
       <label>Info Column Options Wrapper</label> 
       <block type="core/template" name="options_js" template="catalog/product/view/options/js.phtml"/> 
       <block type="catalog/product_view_options" name="product.info.options" as="product_options" template="catalog/product/view/options.phtml"> 
        <action method="addOptionRenderer"><type>text</type><block>catalog/product_view_options_type_text</block><template>catalog/product/view/options/type/text.phtml</template></action> 
        <action method="addOptionRenderer"><type>file</type><block>catalog/product_view_options_type_file</block><template>catalog/product/view/options/type/file.phtml</template></action> 
        <action method="addOptionRenderer"><type>select</type><block>catalog/product_view_options_type_select</block><template>catalog/product/view/options/type/select.phtml</template></action> 
        <action method="addOptionRenderer"><type>date</type><block>catalog/product_view_options_type_date</block><template>catalog/product/view/options/type/date.phtml</template></action> 
      </block> 
        <block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/> 
       </block> 
      <block type="catalog/product_view" name="product.info.options.wrapper.bottom" as="product_options_wrapper_bottom" template="catalog/product/view/options/wrapper/bottom.phtml" translate="label"> 
       <label>Bottom Block Options Wrapper</label> 
       <action method="insert"><block>product.tierprices</block></action> 
       <block type="catalog/product_view" name="product.clone_prices" as="prices" template="catalog/product/view/price_clone.phtml"/> 
       <action method="append"><block>product.info.addtocart</block></action> 
       <action method="append"><block>product.info.addto</block></action> 
      </block> 

をコピーして、

<reference name="right"> 


    HERE    

     <block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/> 
    </reference> 

に入れます楽しい!

関連する問題