0

我已经定制了产品类型(酒店)。它在后端有自定义选项选项卡。

我在某些产品(酒店)中添加了一些自定义选项。我已将 html 添加到自定义主题的 view.phtml 以输出自定义选项。

<?php if ($this->hasOptions()):?> <?php echo $this->getChildHtml('container1','', true, true) ?> <?php endif;?> 

我还在我的布局中添加了块。

            <block type="core/template_facade" name="product.info.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.info.options.wrapper</block></action>
                <action method="append"><block>product.info.options.wrapper.bottom</block></action>
            </block>
            <block type="core/template_facade" name="product.info.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.info.options.wrapper</block></action>
                <action method="append"><block>product.info.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> 

<?php echo $this->getChildHtml('container1','', true, true) ?>返回空。

如何显示选项块?

4

1 回答 1

1

我已经解决了这个问题并在帮助程序中创建了函数来呈现自定义选项。代码如下:

  public function getHotelCustomOptionsHtml(Mage_Catalog_Model_Product $product)
{

    $blockOption = Mage::app()->getLayout()->createBlock("Mage_Catalog_Block_Product_View_Options");
    $blockOption->addOptionRenderer("default","catalog/product_view_options_type_default","catalog/product/view/options/type/default.phtml");
    $blockOption->addOptionRenderer("text","catalog/product_view_options_type_text","inchoo_catalog/product/view/options/type/text.phtml");
    $blockOption->addOptionRenderer("file","catalog/product_view_options_type_file","catalog/product/view/options/type/file.phtml");
      $blockOption->addOptionRenderer("select","catalog/product_view_options_type_select","catalog/product/view/options/type/select.phtml");

    $blockOption->addOptionRenderer("date","catalog/product_view_options_type_date","catalog/product/view/options/type/date.phtml") ;
    $blockOptionsHtml = null;
     if($product->getTypeId() =="hotel")
     {
        $blockOption->setProduct($product);
        if($product->getOptions())
        {
            foreach ($product->getOptions() as $o)
            {
                $blockOptionsHtml .= $blockOption->getOptionHtml($o);
            };
        }
     }

     return $blockOptionsHtml;
}
于 2012-12-15T03:15:20.987 回答