Magento显示相关产品图片


Magento Show Associated Product Images

我正在尝试改变Magento处理产品图像的方式。目前,在可配置产品上,它显示您已上传到可配置产品的图像。

我希望这样,如果产品是可配置的,那么它将只显示相关产品的图像,而不是上传到配置产品的图像。

在我的媒体文件中,我有

<?php foreach ($this->getGalleryImages() as $_image): ?>
    <li><a href="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(70, 70); ?>" width="70"/></a></li>
<?php endforeach; ?>

我可以看到的是从可配置产品的图库中提取图像,所以需要以某种方式更改它,以检查它是否是可配置产品,然后检查它是否只从相关产品中提取图像。

我想检查一下它是否是可配置的,它会是这样的吗?

<?php if ($_product->isSaleable() && (!$_product->isConfigurable() ?>

然后,我需要一些帮助来提取相关产品图像的新代码。

通过在可配置产品上调用getAllowProducts(),您可以从可配置产品中获得一个已使用产品的数组。

foreach ($_product->getAllowProducts() as $_associatedProduct) {
    echo $this->helper('catalog/image')->init($_associatedProduct, 'image')
        ->resize(340,260);
}