2

Magento で発生しているこのエラーについて、助けを求めたいと思います。

致命的なエラー: 163 行目の /Applications/MAMP/htdocs/mysite/app/code/local/Mage/Catalog/Helper/Image.php の非オブジェクトに対するメンバー関数 getData() の呼び出し

CMS ページを作成し、次のコードを使用して template.phtml ファイルを追加しました。

{{block type="core/template" product_id="177" template="page/thumbnails.phtml"}}

テンプレート ファイルには、製品 ID を使用して製品画像とサムネイルが表示されます。コードは view.phtml に配置すると機能しますが、CMS ページに追加するとエラーが発生し、理由がわかりません。

助けていただければ幸いです...

サムネイル.phtml のコード:

                        <?php
    $_product = $this->getProduct();
    $_helper = $this->helper('catalog/output');
    $_gallery = $this->getGalleryImages();
    $_resize = 265;
    ?>
    <style type="text/css">
    .product-img-box .more-views li.slide-current a{ border:2px solid #aaa; }
    .product-img-box .product-image-zoom img { cursor: pointer; }
    #slide-loader{ visibility:hidden; position:absolute; top:auto; left:auto; right:2px;      bottom:2px; width: 25px; height: 25px; }
</style>
<p class="product-image-zoom">
    <?php
        $_img = '<img id="image" src="'.$this->helper('catalog/image')->init($_product, 'image')->resize($_resize).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" onclick="popWin(\''.$this->getGalleryUrl().'.\', \'gallery\', \'width=300,height=300,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes\'); return false;" />';
        echo $_helper->productAttribute($_product, $_img, 'image')
    ?>
    <img id="slide-loader" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" />
</p>
<p class="a-center" id="track_hint"><?php echo $this->__('Click on above image to view full picture') ?></p>

<?php if (count($_gallery) > 0): ?>
<div class="more-views">
    <h4><?php echo $this->__('More Views') ?></h4>
    <ul>
    <?php foreach ($_gallery as $_image): ?>
        <li>
            <a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" onclick="slide('<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize($_resize) ?>',<?php echo ($s = isset($s) ? ++$s : 0) ?>,'<?php echo $this->getGalleryUrl($_image) ?>'); return false;"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
        </li>
    <?php endforeach; ?>
    </ul>
</div>
<?php endif; ?>
<script type="text/javascript">
function slide(url,num,gallery){
    if (typeof slide.loading == 'undefined') slide.loading = false;
    if(slide.loading) return false;

    var loader = new Image();
    $(loader).observe('load', function(){

        $('slide-loader').setStyle({'visibility':'hidden'});

        $$('div.more-views li').each(function(el,i){
            (i==num) ? el.addClassName('slide-current') : el.removeClassName('slide-current');
        });

        var dummy = new Element('img', { src: url }).setOpacity(0);
        new Insertion.After('image', dummy);
        new Effect.Opacity(dummy, { duration:.5, from:0, to:1.0 });
        new Effect.Opacity($('image'), { duration:.5, from:1.0, to:0, 
             afterFinish: function(){
                 $('image').writeAttribute('src',url).setOpacity(1).observe('click',function(e){
                     Event.stop(e);
                     popWin(gallery, 'gallery', 'width=300,height=300,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); 
                     return false;
                 })
                 dummy.remove();
                 slide.loading = false;
             }
        });
    });

    $('slide-loader').setStyle({'visibility':'visible'});
    loader.src=url;
    slide.loading = true;
return false;
});
</script>
4

1 に答える 1

1

このコードを view.phtml で使用すると、ブロック クラスがコア/テンプレートにならないため、「$this->getImageLabel()」などの参照によって、説明したエラーが発生します。

この問題を自分で確認するには、これをview.phtmlとthumbnails.phtmlの両方の先頭に追加してください

echo get_class($this);

その後、インライン静的ブロック タイプを更新できます。記憶から、それはカタログ/製品である可能性がありますが、上記の提案を実行すると、これを簡単に理解できます.

{{block type="catalog/product" product_id="177" template="page/thumbnails.phtml"}}
于 2012-11-24T00:51:48.157 に答える