Skip to content

How AbstractEntity $errorMessageTemplates messages works?

I made a module for export/import a custom model, I’m working with validation messages, I noticed that, when I try to import a CSV without a $_permanentAttributes column, the error message is “columnNotFound”, but when I try to import a product without sku column the message is “We can’t find required columns: sku.”, wich is the message in the ERROR_CODE_COLUMN_NOT_FOUND constant of the AbstractEntity class.

abstract class AbstractEntity implements EntityInterface
{
    ...
    public const ERROR_CODE_COLUMN_NOT_FOUND = 'columnNotFound';
    ...

    /**
     * @var array
     */
    protected $errorMessageTemplates = [
        self::ERROR_CODE_SYSTEM_EXCEPTION => 'General system exception happened',
        self::ERROR_CODE_COLUMN_NOT_FOUND => 'We can't find required columns: %s.',
    ...

Why am I not getting the message “We can’t find required columns: contact_id.” if I have my permanent attribute set correctly?

class Contact extends MagentoImportExportModelImportEntityAbstractEntity
{
    const CONTACT_ID = 'contact_id';
    ...

    protected $_messageTemplates = [
        'invalidContactId' => 'Invalid Contact ID',
    ];

    protected $_permanentAttributes = [self::CONTACT_ID];

    ...