0
我嘗試設置一個新的magento產品圖像,例如che_3.png用:Magento - 如何以編程方式設置媒體庫圖片?
$visibility = array (
'thumbnail',
'small_image',
'image'
);
$product->addImageToMediaGallery($file, $visibility, true, false);
產物圖像從
臨時目錄移動:/media/tmp/catalog/product/upload/sessionid/original/che_3.png
到
目標目錄:/media/catalog/product/c/h/che_3.png
現在,如果我想調用圖像文件路徑 - 由magento保存 - 是錯誤的。該media_gallery對象看起來是這樣的:
[media_gallery] => Array
(
[images] => Array
(
[0] => Array
(
[value_id] => 89
[file] => /c/h/che_3_2_1.png //che_3.svg is already in here
[label] =>
[position] => 1
[disabled] => 0
[label_default] =>
[position_default] => 1
[disabled_default] => 0
)
[1] => Array // why this second item?
(
[value_id] => 88
[file] => /c/h/che_3_2.png
[label] =>
[position] => 1
[disabled] => 0
[label_default] =>
[position_default] => 1
[disabled_default] => 0
)
)
[values] => Array
(
)
)
正如你所看到的文件名是由Magento的延長,也有兩個項目被添加到media_gallery。
我的問題是我如何重置產品分別內部計數器,所以magento使用原始文件,因爲它是?
在此先感謝。
最好的選擇,第二個可能是縮略圖,你檢查過的圖像尺寸是否一樣? – 2012-02-14 19:24:02