【问题标题】:Is it possible use a custom 'select' template for bunlded products in Magento?是否可以在 Magento 中为捆绑产品使用自定义“选择”模板?
【发布时间】:2015-04-25 14:55:20
【问题描述】:

我正在创建一个特定的捆绑产品,它需要对选择和复选框模板进行一些自定义更改。

假设我可以在产品中添加自定义更新布局,但我所做的任何事情似乎都无法针对新的 select.phtml 模板。

<reference name="product.info.options.wrapper">
 <!-- THIS WORKS -->
 <block type="bundle/catalog_product_view_type_bundle" name="product.info.bundle.options" as="type_bundle_options" template="bundle/catalog/product/view/type/bundle/*custom*.phtml">
  <action method="addRenderer">
    <type>select</type>
    <block>bundle/catalog_product_view_type_bundle_option_select</block>  
    <!-- THIS DOESN'T WORK -->
    <template>*custom_folder*/bundle/catalog/product/view/type/bundle/option/*custom*-select.phtml</template>
  </action>
 </block>
 <action method="insert"><block>product.info.bundle.options</block></action>
</reference>

查看catalog.xml,它看起来像复选框,选择等等......指向一个模板,但不在bundle.xml中。

而且,我当然可以覆盖 theme/template/bundle/catalog/...etc../option/select.phtml 中的默认模板 ...但我真的需要一个特定的一种产品的模板......不是全部。

我希望有人对此有所了解?也许我的做法是错误的?

【问题讨论】:

    标签: php magento magento-1.9 magento-1.9.1


    【解决方案1】:

    etc/config.xml

    <frontend>
        <events>
            <core_layout_block_create_after>
                <observers>
                    <change_bundle_select_template>
                        <type>singleton</type>
                        <class>company_module/observer</class>
                        <method>bundleChangeTemplate</method>
                    </change_bundle_select_template>
                </observers>
            </core_layout_block_create_after>
        </events>
    </frontend>
    

    模型/观察者.php

    public function bundleChangeTemplate($observer)
    {
        if ($observer->getBlock() instanceof Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Select) {
            $observer->getBlock()->setTemplate('bundle/catalog/product/view/type/bundle/option/sel.phtml');
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-30
      相关资源
      最近更新 更多