PHP错误:未定义的偏移量:1-LemonStand产品导出
尝试在LemonStand中导出产品图像时,我不断遇到以下错误:PHP错误:未定义的偏移量:1-LemonStand产品导出,php,Php,尝试在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_nam
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);
$image\u path
不包含“|”
,因此分解它时,结果仅包含1项(of set 0
),第二项(of set 1
试图存储在$file\u name
)中的内容不存在
因此,您的解决方案可以是确保$image_路径
包含必要的'.
,或者以不同方式处理$image_路径
,而不使用'.