没有在类别页面中获取产品图像

时间:2016-02-20 17:21:16

标签: magento magento-1.8

我仍然是Magento的新手。我正在尝试在我的自定义主题的类别列表页面上显示产品图像,但不知何故,这会在页面呈现后显示有机terra红花油,并且链接似乎已损坏,虽然文件存在于位置和所有必要的文件权限。我已经搜索了论坛并尝试了所有可能的修复,从刷新缓存和重新索引到无济于事。

<?php $_productCollection=$this->getLoadedProductCollection();
    $_helper = $this->helper('catalog/output');?>
    <?php $_iterator = 0; ?>
    <?php $_columnCount = $this->getColumnCount(); ?>
    <section class="container">
      <?php $i=0; foreach ($_productCollection as $_product): ?>
      <?php if ($i++%$_columnCount==0): ?>    
      <div class="row<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
       <?php endif ?>
      <div class="four columns">
        <div class="productDisplay">
          <div class="productImage">
             <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="img-responsive"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image'); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
          </div>          
          <hr style="width:20%; margin-top: 11px; margin-bottom: 12px; margin-left: auto;">
          <div class="productName"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></div>
          <div class="productPrice"><?php echo $this->getPriceHtml($_product, true) ?></div>
          <?php if($_product->isSaleable()): ?>
            <button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="addToCartButton button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
              <?php else: ?>
                <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                <?php endif; ?>
          </div> 
       </div>   
      <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
      </div>
      <?php endif ?>
      <?php endforeach ?>   
    </section>
<!-- Script for Pop-Out side Menu-->
<!-- Created by Sayan Sarkar on 21/01/2016 -->
<script>
(function() {
  var body = $('body');
  $('.categoryButton').bind('click', function(){
      body.toggleClass('menu-open');
      return false;
  });
})();
(function() {
  var body = $('body');
  $('.menuclose').bind('click', function(){
      body.toggleClass('menu-open');
      return false;
  });
})();
</script>

首先,我很困惑为什么产品图片出现在产品详细信息页面中时会显示默认图像。任何帮助将受到高度赞赏。

1 个答案:

答案 0 :(得分:0)

获取产品图片。试试这个

  <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(250); ?>" 
alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
相关问题