この種のストアでは、製品 (メガネと衣類) ごとに異なる属性セットを使用することをお勧めします。ただし、商品の種類を示す別の属性 ( 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;
}
提供したいさまざまなディメンションに関して微調整を行う必要があることは間違いありませんが、それでも非常に優れたコード (ここで入手可能) であり、何度も私の背中を救ってくれました。
それが役に立てば幸い。