2013-02-20 64 views
1

我試圖顯示每個產品顯示位置的商品品牌,包括缺省情況下通常顯示在右側的結帳購物車塊。將自定義屬性添加到magento1.7購物車側欄

我已經嘗試了幾個方法,但其中一個似乎已經工作。

車/側邊欄/ default.phtml

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

這會導致內存不足的錯誤,所以我試圖用獲得自定義屬性,並傳遞給它的屬性的名稱,但沒有任何工作。獲取自定義屬性纔會返回NULL

默認/佈局/ 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

請試試這個。刪除您定製的所有東西。只需添加下面的代碼。你會看到神奇

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

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

上面的代碼是working.Tested在1.7.0.2

+0

你先生已經迷住了我的代碼,並使其工作,我感謝你。 – 2013-02-20 14:33:39

相關問題