如何使用Magento中的getThumbnailUrl()从类别中显示缩略图

use*_*007 1 html javascript php jquery magento

我试图做这项工作,但没有运气,基本上我需要在内容块上显示主菜单类别,我做了,但现在我需要在内容块中显示类别名称旁边的缩略图类别.我在app/desing/fronend/default/THEME/template/catalog/navigation/category_listing.php中创建了一个新的自定义模块,如下所示:

<div class="box layered-nav">
    <div class="head">
    </div>
    <div class="border-creator">
      <div class="narrow-by">
          <dl id="narrow-by-list">

         <dd>
         <ol>        
        <?php foreach ($this->getStoreCategories() as $_category): ?>
            <dt>
             <a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="active"<?php endif ?>><?php echo $this->htmlEscape($_category->getName()) ?>
             <img src="<?php echo $_category->getThumbnailUrl() ?>" width="100" height="100" style="background:red; height: 100px; width: 100px; display: block" alt="<?php echo $this->htmlEscape($_category->getName()) ?>" />
             </a> 

            </dt>
        <?php endforeach ?>

       </ol>
      </dd>
      </dl><script type="text/javascript">decorateDataList('narrow-by-list')</script>
    </div>
   </div>
</div>
Run Code Online (Sandbox Code Playgroud)

然后我将其添加到app/code/core/Mage/Catalog/model/Categorie.php

            public function getThumbnailUrl()
            {
                $url = false;
                if ($image = $this->getThumbnail()) {
                    $url = Mage::getBaseUrl('media').'catalog/category/'.$image;
                }
                return $url;
            }
Run Code Online (Sandbox Code Playgroud)

任何想法为什么不拉动和显示图像?我已经使用管理面板添加到类别中,清除了缓存并刷新了数据,任何想法?

Magento和Firebug

小智 5

使用以下功能显示类别缩略图图像

   public function getThumbnailImageUrl() 
   {
      $url = false;

      if ($image = $this->getThumbnail()) {

         $url = Mage::getBaseUrl('media').'catalog/category/'.$image;
      }
      return $url;
   }
Run Code Online (Sandbox Code Playgroud)

然后,使用任何类别:

$ _imageUrl = $这 - > getCurrentCategory() - > getThumbnailImageUrl()

你可以得到缩略图.

请参阅此文章 http://www.douglasradburn.co.uk/getting-category-thumbnail-images-with-magento/