2013-02-20 57 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

相关问题