@@ -314,12 +314,6 @@ class Product extends JobImport
314
314
* @var CollectionFactory $categoryCollectionFactory
315
315
*/
316
316
protected $ categoryCollectionFactory ;
317
- /**
318
- * The default name value when empty
319
- *
320
- * @var ?array $defaultNameValue
321
- */
322
- protected $ defaultNameValue = null ;
323
317
324
318
/**
325
319
* Product constructor.
@@ -784,8 +778,6 @@ public function insertData()
784
778
}
785
779
}
786
780
787
- $ product = $ this ->handleNoName ($ product );
788
-
789
781
/** @var bool $result */
790
782
$ result = $ this ->entitiesHelper ->insertDataFromApi (
791
783
$ product ,
@@ -2457,6 +2449,8 @@ public function setValues()
2457
2449
);
2458
2450
}
2459
2451
2452
+ $ this ->handleNoName ();
2453
+
2460
2454
if ($ this ->configHelper ->isAdvancedLogActivated ()) {
2461
2455
$ this ->logImportedEntities ($ this ->logger , true , 'identifier ' );
2462
2456
}
@@ -5132,29 +5126,28 @@ private function updateProductVisibility(string $tmpTable, array $mappings): arr
5132
5126
}
5133
5127
5134
5128
/**
5135
- * If product has no name in Akeneo, give it an empty string name
5129
+ * Set default product name for default if empty
5136
5130
*/
5137
- protected function handleNoName (array $ product ): array
5131
+ protected function handleNoName (): void
5138
5132
{
5139
- if (array_key_exists (ProductInterface::NAME , $ product ['values ' ])) {
5140
- return $ product ;
5141
- }
5133
+ $ connection = $ this ->entitiesHelper ->getConnection ();
5142
5134
5143
- if ($ this ->defaultNameValue === null ) {
5144
- try {
5145
- $ attribute = $ this ->akeneoClient ->getAttributeApi ()->get (ProductInterface::NAME );
5146
- $ this ->defaultNameValue = [
5147
- 'locale ' => ($ attribute ['localizable ' ] ?? false ) ? $ this ->storeHelper ->getAdminLang () : null ,
5148
- 'scope ' => ($ attribute ['scopable ' ] ?? false ) ? $ this ->configHelper ->getAdminDefaultChannel () : null ,
5149
- 'data ' => '' ,
5150
- ];
5151
- } catch (Exception ) {
5152
- $ this ->defaultNameValue = ['locale ' => null , 'scope ' => null , 'data ' => '' ];
5153
- }
5135
+ $ columnIdentifier = $ this ->entitiesHelper ->getColumnIdentifier (
5136
+ $ this ->entitiesHelper ->getTable ('catalog_product_entity ' )
5137
+ );
5138
+
5139
+ $ attribute = $ this ->eavConfig ->getAttribute ('catalog_product ' , ProductInterface::NAME );
5140
+ if (!$ attribute ) {
5141
+ return ;
5154
5142
}
5155
5143
5156
- $ product ['values ' ][ProductInterface::NAME ][0 ] = $ this ->defaultNameValue ;
5144
+ $ tmpTable = $ this ->entitiesHelper ->getTableName ($ this ->jobExecutor ->getCurrentJob ()->getCode ());
5145
+ $ entityTable = $ this ->entitiesHelper ->getTable ('catalog_product_entity ' );
5146
+ $ entityVarcharTable = $ this ->entitiesHelper ->getTable ('catalog_product_entity_varchar ' );
5157
5147
5158
- return $ product ;
5148
+ $ connection ->query ('INSERT IGNORE INTO ` ' . $ entityVarcharTable . '`
5149
+ (`attribute_id`, `store_id`, `value`, ` ' . $ columnIdentifier . '`)
5150
+ SELECT ' . $ attribute ->getId () . ', 0, NULL, ` ' . $ columnIdentifier . '` FROM ` ' . $ entityTable . '` e
5151
+ INNER JOIN ` ' . $ tmpTable . '` t ON e.`entity_id` = t.`_entity_id` ' );
5159
5152
}
5160
5153
}
0 commit comments