質問

閉じられた 4年前>。

私はちょうどアイテムすべての後にアイテムIDを望んでいて、データベースからいくつかの情報を取得することができるが、常に最初の項目のIDを表示している これは私のXML

です
<layout version="0.1.0">
<adminhtml_sales_order_view>
    <reference name="order_item_extra_info">
        <block type="core/template" name="cgorder_wrap_container" template="customsales/sales/cgorder_details_container.phtml">
            <!-- Replace it with your OWN block -->
            <block type="core/template" name="own_real_block" template="customsales/sales/cgorder_details.phtml" />
        </block>
    </reference>
</adminhtml_sales_order_view>
.

これは私の親テンプレートファイル

です
<tr>
<td><?php echo $this->getChildHtml();?></td>
<td colspan="8"></td></tr>
.

これは私の子テンプレートファイル

です
<?php
$id = $this->getParentBlock()->getParentBlock()->getItem()->getID();
echo "id is ".$id;
?>
.

画像の説明が入力されています

役に立ちましたか?

解決

<block type="core/text_list" name="order_item_extra_info"></block>の子としてあなたのブロックを追加してみてください。それはこのように見えるべきです:

レイアウト:

<adminhtml_sales_order_view>
    <reference name="order_item_extra_info">
        <block type="core/template" name="own_name" template="sales/test.phtml" />
    </reference>
</adminhtml_sales_order_view>
.

テンプレートsales/test.phtml(ラッパー、テーブル構造):

<tr>
    <td><?php echo $this->getParentBlock()->getItem()->getId();?></td>
    <td colspan="8"></td>
</tr>
.

ここでの結果(807と809はアイテムIDです):
結果

PS:テンプレートにテーブル構造を保存することを忘れないでください。

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top