使用不同的属性集为每种产品(眼镜&服装)是这种类型的商店一个非常好的主意。但是,您也可以尝试提供产品类型的单独属性(在glasses
& clothing
之间)。
关于调整图像大小,我发现了一个非常容易使用的脚本,其代码如下: -
public function resizeImage($imageName, $width=NULL, $height=NULL, $imagePath=NULL) {
$imagePath = str_replace("/", DS, $imagePath);
$imagePathFull = Mage::getBaseDir('media') . DS . $imagePath . DS . $imageName;
if ($width == NULL && $height == NULL) {
$width = 100;
$height = 100;
}
$resizePath = $width . 'x' . $height;
$resizePathFull = Mage::getBaseDir('media') . DS . $imagePath . DS . $resizePath . DS . $imageName;
if (file_exists($imagePathFull) && !file_exists($resizePathFull)) {
$imageObj = new Varien_Image($imagePathFull);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->resize($width, $height);
$imageObj->save($resizePathFull);
}
$imagePath = str_replace(DS, "/", $imagePath);
return Mage::getBaseUrl("media") . $imagePath . "/" . $resizePath . "/" . $imageName;
}
你肯定会需要做的关于要提供不同尺寸的一些调整,但它仍然是一段非常好的代码(available here),它已经多次挽回了我的后遗症。
希望它有帮助。
借调属性集是一种很好的(也许是“正确的”)方法来实现这一点。 –
@Joseph - 干杯! –