尝试在LemonStand中导出产品图片时,我一直收到以下错误:
Phpr_PhpException: Undefined offset: 1. In /public_html/store/modules/shop/classes/shop_productexport.php, line 158
以下是有问题的代码:
// Images should be separated by newlines, and each should be in
// in {disk_name}|{real_name} format
protected static function get_images_for_export($row, $base_path = 'images', &$images_to_export = null)
{
if (empty($row['images']))
return $row;
$image_paths = explode("\n", $row['images']);
$row['images'] = array();
foreach ($image_paths as $image_path)
{
list($disk_name, $file_name) = explode('|', $image_path, 2);
$new_name = preg_replace('/[^\w_\.-]+/u', '_', $row['sku'].'-'.$file_name);
$row['images'][] = $base_path.'/'.$new_name;
$images_to_export[$disk_name] = $new_name;
}
$row['images'] = join(",", $row['images']);
return $row;
}
第158行是:
list($disk_name, $file_name) = explode('|', $image_path, 2);
答案 0 :(得分:0)
$image_path
不包含'|'
,因此在展开时,结果只包含1项(ofsset 0
)和第2项(ofsset 1
尝试存储在$file_name
)中不存在。
因此,您的解决方案是确保$image_path
包含必要的'|'
或处理$image_path
而不使用'|'
。