181 self::ERROR_ROW_IS_ORPHAN,
182 __(
'Orphan rows that will be skipped due default row errors')
185 $this->_availableBehaviors = [
191 if (isset(
$data[
'customer_data_source_model'])) {
192 $this->_dataSourceModels[
'customer'] =
$data[
'customer_data_source_model'];
197 $this->_dataSourceModels[
'customer'] = $dataFactory->create([
'arguments' =>
$arguments]);
199 if (isset(
$data[
'customer_entity'])) {
200 $this->_customerEntity =
$data[
'customer_entity'];
202 $data[
'data_source_model'] = $this->_dataSourceModels[
'customer'];
204 unset(
$data[
'data_source_model']);
206 $this->_initCustomerAttributes();
209 if (isset(
$data[
'address_data_source_model'])) {
210 $this->_dataSourceModels[
'address'] =
$data[
'address_data_source_model'];
216 $this->_dataSourceModels[
'address'] = $dataFactory->create([
'arguments' =>
$arguments]);
218 if (isset(
$data[
'address_entity'])) {
219 $this->_addressEntity =
$data[
'address_entity'];
221 $data[
'data_source_model'] = $this->_dataSourceModels[
'address'];
223 unset(
$data[
'data_source_model']);
225 $this->_initAddressAttributes();
228 if (isset(
$data[
'next_customer_id'])) {
229 $this->_nextCustomerId =
$data[
'next_customer_id'];
231 $this->_nextCustomerId = $resourceHelper->getNextAutoincrement($this->_customerEntity->getEntityTable());
240 protected function _initCustomerAttributes()
243 foreach ($this->_customerEntity->getAttributeCollection() as
$attribute) {
244 $this->_customerAttributes[] =
$attribute->getAttributeCode();
255 protected function _initAddressAttributes()
258 foreach ($this->_addressEntity->getAttributeCollection() as
$attribute) {
259 $this->_addressAttributes[] =
$attribute->getAttributeCode();
272 $result = $this->_customerEntity->importData();
274 return $result && $this->_addressEntity->setCustomerAttributes($this->_customerAttributes)->importData();
287 return 'customer_composite';
297 $this->_customerEntity->prepareCustomerData(
$source);
307 $this->_addressEntity->prepareCustomerData($rows);
309 return parent::validateData();
322 if ($rowScope == self::SCOPE_DEFAULT) {
323 if ($this->_customerEntity->validateRow($rowData, $rowNumber)) {
324 $this->_currentWebsiteCode =
326 $this->_currentEmail = strtolower(
331 $websiteId = $this->_customerEntity->getWebsiteId($this->_currentWebsiteCode);
332 if (!$this->_addressEntity->getCustomerStorage()->getCustomerId($this->_currentEmail,
$websiteId)) {
333 $this->_addressEntity->getCustomerStorage()->addCustomerByArray(
335 'entity_id' => $this->_nextCustomerId,
336 'email' => $this->_currentEmail,
340 $this->_nextCustomerId++;
345 $this->_currentWebsiteCode =
null;
346 $this->_currentEmail =
null;
349 if (!empty($this->_currentWebsiteCode) && !empty($this->_currentEmail)) {
352 $this->
addRowError(self::ERROR_ROW_IS_ORPHAN, $rowNumber);
373 if (empty($rowData)) {
382 return $this->_addressEntity->validateRow($rowData, $rowNumber);
402 foreach ($rowData as $key =>
$value) {
403 if (!in_array($key, $this->_customerAttributes) && !empty(
$value)) {
404 if (!in_array($key, $excludedAttributes)) {
405 $key = str_replace(self::COLUMN_ADDRESS_PREFIX,
'', $key);
438 parent::setParameters($parameters);
444 $this->_customerEntity->setParameters($parameters);
445 $this->_addressEntity->setParameters($parameters);
458 $this->_customerEntity->setSource(
$source);
459 $this->_addressEntity->setSource(
$source);
461 return parent::setSource(
$source);
471 return $this->_customerEntity->getProcessedEntitiesCount() +
472 $this->_addressEntity->getProcessedEntitiesCount();
483 if (in_array(str_replace(self::COLUMN_ADDRESS_PREFIX,
'',
$attributeCode), $this->_addressAttributes)) {
504 return parent::_prepareRowForDb($rowData);
514 $this->validColumnNames,
515 $this->_customerAttributes,
516 $this->_addressAttributes,
517 $this->_customerEntity->getValidColumnNames()
setParameters(array $parameters)
const COLUMN_DEFAULT_SHIPPING
const BEHAVIOR_ADD_UPDATE
addRowError( $errorCode, $errorRowNum, $colName=null, $errorMessage=null, $errorLevel=ProcessingError::ERROR_LEVEL_CRITICAL, $errorDescription=null)
validateRow(array $rowData, $rowNumber)
_prepareAddressRowData(array $rowData)
const COLUMN_DEFAULT_BILLING
const COLUMN_ADDRESS_PREFIX
const ERROR_ROW_IS_ORPHAN
const COMPONENT_ENTITY_CUSTOMER
const COLUMN_DEFAULT_SHIPPING
_validateAddressRow(array $rowData, $rowNumber)
setSource(\Magento\ImportExport\Model\Import\AbstractSource $source)
getBehavior(array $rowData=null)
_prepareRowForDb(array $rowData)
_getRowScope(array $rowData)
const COLUMN_DEFAULT_BILLING
addMessageTemplate($errorCode, $message)
getProcessedEntitiesCount()
isAttributeParticular($attributeCode)
__construct(\Magento\Framework\Stdlib\StringUtils $string, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\App\ResourceConnection $resource, ProcessingErrorAggregatorInterface $errorAggregator, \Magento\CustomerImportExport\Model\ResourceModel\Import\CustomerComposite\DataFactory $dataFactory, \Magento\CustomerImportExport\Model\Import\CustomerFactory $customerFactory, \Magento\CustomerImportExport\Model\Import\AddressFactory $addressFactory, array $data=[])
const COMPONENT_ENTITY_ADDRESS