经过深思熟虑,除了创建自己的处理器外,我找不到任何合适的解决方案。这是解决方案
public class MediaProcessor extends DefaultImportProcessor
{
@Override
public void init(final ImpExImportReader reader)
{
super.init(reader);
}
@Override
public Item processItemData(final ValueLine valueLine) throws ImpExException
{
Item item = null;
final ValueEntry codeEntry = valueLine.getValueEntry(2);
final String mediaCode = codeEntry.getCellValue();
if (StringUtils.isNotEmpty(mediaCode))
{
item = super.processItemData(valueLine);
}
return item;
}
}
Impex应该是这样的..
INSERT_UPDATE Media[processor=com.hybris.core.impex.processor.MediaProcessor];mediaFormat(qualifier);code[unique=true];youtubeURL;mime[default='video/mp4'];$catalogVersion;folder(qualifier)[default=images]
这不会挽救错误。但它不会在我进入控制台时抛出空指针异常(一个大人物真的很讨厌这个)。因此,如果code = null
系统将转储该行并继续下一步。
更新 :
快速破解解决了我的问题。如果 code = null (根据我的要求),这是转储完整行的正确解决方案
一条线让一切都像魅力一样工作!!!
valueLine.resolve(item, Collections.EMPTY_LIST);
完整代码
public class MediaProcessor extends DefaultImportProcessor
{
@Override
public void init(final ImpExImportReader reader)
{
super.init(reader);
}
@Override
public Item processItemData(final ValueLine valueLine) throws ImpExException
{
Item item = null;
final ValueEntry codeEntry = valueLine.getValueEntry(2);
final String mediaCode = codeEntry.getCellValue();
if (StringUtils.isNotEmpty(mediaCode))
{
item = super.processItemData(valueLine);
}
else
{
valueLine.resolve(item, Collections.EMPTY_LIST);
}
return item;
}
}