【发布时间】:2012-02-14 14:39:10
【问题描述】:
我尝试设置一个新的 magento 产品图片,例如che_3.png 与:
$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 使用原始文件?
提前致谢。
【问题讨论】:
-
最好,第二个可能是缩略图,你检查两个图像尺寸是否相同?