简体   繁体   English

显示magento中类别的不同产品图像

[英]Display different product images for categories in magento

I am developing a magento website for a company solely selling jumpers. 我正在为一家仅销售跳线的公司开发一个magento网站。 each jumper can have three images, 每个跳线可以包含三个图像,

image 1: jumper with no model image 2. male model wearing jumper image 3: female model wearing jumper 图像1:无模型的跳线图像2:男性模型的跳线图像3:女性模型的跳线

some jumpers will have all 3 and some will have either the base image and either the male or female image 有些跳线将全部使用3,有些跳线将使用基本图像以及男性或女性图像

On the homepage i display the jumper images with no model. 在主页上,我显示没有模型的跳线图像。

I want to create 2 categories (male , female) 我想创建2个类别(男,女)

when lets say the male category page is selected, i would like to show the male images in this page. 当可以说选择了男性类别页面时,我想在此页面中显示男性图像。

any ideas how i would do this? 任何想法,我将如何做到这一点?

One of the quickest ways I can think of to accomplish this, if you dont want to create duplicate product is: 如果您不想创建重复的产品,我可以想到的最快方法之一是:

In Admin -> Product -> Image Tab 在管理员->产品->图片标签中

Always select 'thumbnail' on a female pic and 'small_image' for a male (you could also create you own image type see below) 始终在女性图片上选择“缩略图”,为男性选择“ small_image”(您也可以创建自己的图像类型,请参见下文)

in /app/design/frontend/default/contempospace/template/catalog/product/list.phtml 在/app/design/frontend/default/contempospace/template/catalog/product/list.phtml中

if([category == female])
     <img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(170, 174); ?>
else
     <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(170, 174); ?>

You could also add a new image type, one for male and female. 您还可以添加一种新的图像类型,一种用于男性和女性。

How to add a new image type in Magento : 如何在Magento中添加新的图像类型:

Go Admin -> Catalog -> Attribute -> Manage Attribute 转到管理员->目录->属性->管理属性

Then create a new attribute of 'Media Image' for 'Catalog Input Type for Store Owner' 然后为“商店所有者的目录输入类型”创建一个新属性“媒体图像”

See How to get access to custom Image Attribute in list.phtml in Magento 请参阅Magento中list.phtml中的如何访问自定义图像属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM