編輯:這是我現在有:Magento的:添加屬性「list.phtml」爲比較
_______________
我想這個信息是上述添加到購物車按鈕:
這裏是從產品頁面的代碼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>
怎麼了?
我將如何實現呢?? –
只需用$ _item-> getProduct()替換$ _product,或者在頂部添加以下行: $ _product = $ _item-> getProduct(); – dagfr