相关产品的放置 - Magento

Mar*_*-bt 2 magento

我有一个magento安装,我需要在中心列中放置相关产品.这是简单的部分.我搬家了

<block type="catalog/product_list_related" name="catalog.product.related" after="container1" template="catalog/product/list/related.phtml"/>
Run Code Online (Sandbox Code Playgroud)

从右侧参考块到中心参考块的底部.

有了这个,我实现了将相关产品放在中间列,但一直在底部.

我需要将相关产品放在div的价格块上方(类:product-shop)

我尝试使用XML中的After/before参数来定位它,但这似乎不起作用.

如果我将块代码放在XML中更高的位置,它根本不会显示.

ben*_*rks 10

移动块很容易正确(即使用最佳实践).最佳实践包括尽可能自定义任何核心布局文件以及使用原始块实例而不是重新实例化它们.所有这些都可以使用最终实现者可用的自定义布局文件来实现.

在自定义主题的布局文件夹中创建一个local.xml文件,例如app/design/frontend/[package]/[theme] /layout/local.xml,并在其中添加以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<layout>
    <!--
        In Magento v1 a move is accomplished by unsetting in one place
        and inserting in another. This is possible using just layout xml
        when the "new" parent block is a "Mage_Core_Block_Text_List"
        instance. Otherwise a template needs editing.

        In Magento v2 there will be actual "move" functionality.
    -->
    <catalog_product_view>
        <reference name="right">
            <!-- remove the block name from a parent -->
            <action method="unsetChild">
                <block>catalog.product.related</block>
            </action>
        </reference>
        <reference name="content">
            <!-- add the block name to a parent -->
            <action method="insert">
                <block>catalog.product.related</block>
            </action>
            <!--
                Mage_Core_Block_Abstract::insert() accepts multiple arguments,
                but by default it will insert the added block at the beginning
                of the list of child blocks.
            -->
        </reference>
    </catalog_product_view>
</layout>
Run Code Online (Sandbox Code Playgroud)

此时,您可以将更改还原为原始布局xml文件.