2012-12-18 53 views
1

编辑:这是我现在有:Magento的:添加属性“list.phtml”为比较

compare

_______________
我想这个信息是上述添加到购物车按钮:

enter image description here


这里是从产品页面的代码NOW:
`getProductUrl($ _ item)?>',true)“title =”stripTags($ _ item-> getName(),null,true)?>“> helper('catalog/image') - > init($ _ item ,'small_image') - >调整大小(125,125); ?>”宽度= “125” HEIGHT = “125” ALT = “stripTags($ _用品 - >的getName(),NULL,真)?>”/>

   <h2 class="product-name"><a href="#" onclick="setPLocation('<?php echo $this->getProductUrl($_item) ?>', true)" title="<?php echo $this->stripTags($_item->getName(), null, true) ?>"><?php echo $this->helper('catalog/output')->productAttribute($_item, $_item->getName(), 'name') ?></a></h2> 

       <?php echo $this->getReviewsSummaryHtml($_item, 'short') ?> 
       <?php echo $this->getPriceHtml($_item, true, '-compare-list-top') ?> 
       <?php if($_item->isSaleable()): ?> 
        <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setPLocation('<?php echo $this->helper('catalog/product_compare')->getAddToCartUrl($_item) ?>', true)"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p> 
       <?php else: ?> 
        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p> 
       <?php endif; ?> 
       <?php if ($this->helper('wishlist')->isAllow()) : ?> 
        <ul class="add-to-links"> 
         <li><a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist" onclick="setPLocation(this.href, true)"><?php echo $this->__('Add to Wishlist') ?></a>` 



和这里是代码从产品页,我(天真)尝试复制了..
<?php echo (($_product->getResource()->getAttribute('hersteller')->getFrontend()->getValue($_product) && $_product->getResource()->getAttribute('hersteller')->getFrontend()->getValue($_product) != "Nein") ? $_product->getResource()->getAttribute('hersteller')->getFrontend()->getValue($_product) : ''); ?> <?php echo (($_product->getResource()->getAttribute('weingut')->getFrontend()->getValue($_product) && $_product->getResource()->getAttribute('weingut')->getFrontend()->getValue($_product) != "Nein") ? $_product->getResource()->getAttribute('weingut')->getFrontend()->getValue($_product) : ''); ?> <?php echo (($_product->getResource()->getAttribute('ob_hersteller')->getFrontend()->getValue($_product) && $_product->getResource()->getAttribute('ob_hersteller')->getFrontend()->getValue($_product) != "Nein") ? $_product->getResource()->getAttribute('ob_hersteller')->getFrontend()->getValue($_product) : ''); ?>


旧后
我想更多的属性添加到在Magento比较页面,但我得到以下错误,当我添加在产品页面上成功处理的代码。


我的产品页面有以下几点:

*图像
*型号名称
*价格
*添加到购物车按钮

我想下面的INSTEAD:

*图像
*品牌或葡萄园或Destillery
*型号名称
*价格
*股票
*交货时间

*添加到购物车按钮


这是我有它在我的产品页面的“LIS t.phtml”。然而,当我的代码复制到比较“list.phtml”我得到以下错误:

Fatal error: Call to a member function getResource() on a non-object in ........./app/design/frontend/base/default/template/catalog/product/compare/list.phtml on line 68


这里是用代码协同工作的产品页面:
http://weinwerk-klimascout.de/obstbrand/selection-kirsch.html

这里是代码:

<h2> 
    <?php echo (($_product->getResource()->getAttribute('hersteller')->getFrontend()->getValue($_product) && $_product->getResource()->getAttribute('hersteller')->getFrontend()->getValue($_product) != "Nein") ? $_product->getResource()->getAttribute('hersteller')->getFrontend()->getValue($_product) : ''); ?> 
    <?php echo (($_product->getResource()->getAttribute('weingut')->getFrontend()->getValue($_product) && $_product->getResource()->getAttribute('weingut')->getFrontend()->getValue($_product) != "Nein") ? $_product->getResource()->getAttribute('weingut')->getFrontend()->getValue($_product) : ''); ?> 
    <?php echo (($_product->getResource()->getAttribute('ob_hersteller')->getFrontend()->getValue($_product) && $_product->getResource()->getAttribute('ob_hersteller')->getFrontend()->getValue($_product) != "Nein") ? $_product->getResource()->getAttribute('ob_hersteller')->getFrontend()->getValue($_product) : ''); ?> 
</h2> 

怎么了?


回答

2

您不必在此模板的$ _产品变量,你应该使用$ _item-> getProduct()代替;)

问候,

+0

我将如何实现呢?? –

+1

只需用$ _item-> getProduct()替换$ _product,或者在顶部添加以下行: $ _product = $ _item-> getProduct(); – dagfr