1

通常はデフォルトで右側に表示されるチェックアウトカートブロックを含め、商品が表示されるすべての場所に商品のブランドを表示しようとしています。

私はいくつかの方法を試しましたが、そのうちの1つはうまくいったようです。

カート/サイドバー/default.phtml

$_item  = $this->getItem();
$_product   = $_item->getProduct()->load();
$attributes = $_product->getAttributes();

これによりメモリエラーが発生するため、get custom属性を使用して属性の名前を渡そうとしましたが、それも機能しませんでした。カスタム属性の取得はNULLのみを返しました

default / layout / checkout.xml

 <default>

    <!-- Mage_Checkout -->
    <reference name="top.links">
        <block type="checkout/links" name="checkout_cart_link">
            <action method="addCartLink"></action>
            <action method="addCheckoutLink"></action>
        </block>
    </reference>
    <reference name="right">
        <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
            <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
            <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
            <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
            <block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
                <label>Shopping Cart Sidebar Extra Actions</label>
                <action method="addAttribute"><attribute>brand</attribute></action>
            </block>
        </block>
    </reference>
</default>

私はこれを編集して、カスタムブランド属性を含めると思います。これを正しく理解すれば、サイドバーカートでアクセスできるようになります...

この時点から、今何が欠けているのかわかりません。

4

1 に答える 1

4

これを試してください。カスタマイズしたものをすべて削除します。以下のコードを追加するだけです。そしてあなたは魔法を見るでしょう

    <?php $_product= Mage::getSingleton('catalog/product')->load($_item->getProductId()) ?>

    <?php echo $_product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($_product); 

上記のコードは機能しています.1.7.0.2でテスト済み

于 2013-02-20T13:53:06.177 に答える