使用 PHP 从更多视图中排除基本映像(不使用排除框)


Exclude Base Image from More Views using PHP (Not with Exclude Box)

我遇到了一个Magento问题,其中选择作为基本图像的图像显示两次,一次作为主图像,一次作为"更多视图"图像。问题是基本图像尚未在所有成千上万的产品上被检查为"排除"。

是否有一种Magento方法可以拉取完整的图像库,无论是否选中"排除",或者拉取除被选为"基本图像"的图像之外的所有图像。

当前代码

<a href="<?php echo $helpImg->getImg($_product, $imgWidth, $imgHeight); ?>" title="<?php echo $this->escapeHtml($this->getImageLabel());?>" />
   <img src="<?php echo $helpImg->getImg($_product, $imgWidth, $imgHeight); ?>" alt="<?php echo $this->escapeHtml($this->getImageLabel());?>" title="<?php echo $this->escapeHtml($this->getImageLabel());?>" />
</a>
<?php if (count($this->getGalleryImages()) > 1): ?>
   <?php foreach ($this->getGalleryImages() as $_image): ?>
        <a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize($additionalImageSize[0], $additionalImageSize[1]); ?>" class="swipebox"  title="<?php echo $this->escapeHtml($this->getImageLabel());?>" />
              <img data-src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize($additionalImageSize[0], $additionalImageSize[1]); ?>" alt="<?php echo $subtitle; ?>" title="<?php echo $this->escapeHtml($this->getImageLabel());?>"/>
        </a>
   <?php endforeach; ?><?php endif; ?>

当前,它拉取主图像,然后拉取图库。我试图只拉取整个图库而不考虑"排除",或者拉取除基本图像以外的图库。

想法?

已找到解决方案

.PHP

<?php
  if ($_product->getImage() == $_image->getFile())
     continue;
?>

直接在 foreach 语句之后添加了这个,现在它拉取除第一个图像之外的所有图像。