使用不同的屬性集爲每種產品(眼鏡&服裝)是這種類型的商店一個非常好的主意。但是,您也可以嘗試提供產品類型的單獨屬性(在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 - 乾杯! –