1

編集:これが私が今持っているものです:

比較

_______________
この情報を[カートに追加]ボタンの上に配置したい:

ここに画像の説明を入力してください


現在の製品ページのコードは次のとおり
です。`getProductUrl($ _ item)?>'、true)" title = "stripTags($ _ item-> getName()、null、true)?>"> helper(' catalog / image ')-> init($ _ item、' small_image')-> resize(125、125);?> "width =" 125 "height =" 125 "alt =" stripTags($ _ item-> getName()、null、 true)?> "/>

                <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>`



これが、私が(素朴に)コピーしようとしているPRODUCTPAGEのコードです。
<?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の比較ページに属性を追加しようとしていますが、製品ページで正常に機能するコードを追加すると、次のエラーが発生します。


私の製品ページには次のものがあります:

*画像
*モデル名
*価格
*カートに追加ボタン

私は次のようになります:

*画像
*ブランドまたはブドウ園または蒸留所
*モデル名
*価格
*在庫あり
*納期

*カートに追加ボタン


これが私の製品ページの「list.phtml」にある方法です。ただし、そのコードを比較「list.phtml」にコピーすると、次のエラーが発生します。

致命的なエラー:オンラインの......... / app / design / frontend / base / default / template / catalog / product / compare / list.phtml内の非オブジェクトでメンバー関数getResource()を呼び出す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>

どうしたの?


4

1 に答える 1

2

このテンプレートには $_product 変数がありません。代わりに $_item->getProduct() を使用する必要があります;)

よろしく、

于 2012-12-18T22:58:59.880 に答える