Skip to content

Commit 80de21f

Browse files
authored
Merge pull request #696 from akeneo/release/104.3.8
Release/104.3.8
2 parents 1815946 + 966125a commit 80de21f

File tree

3 files changed

+23
-27
lines changed

3 files changed

+23
-27
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -487,3 +487,6 @@
487487

488488
### Version 104.3.7 :
489489
* PGTO-430: Allow to assign an image to the parent or child only
490+
491+
### Version 104.3.8 :
492+
* PGTO-433: Product default name logic

Job/Product.php

+19-26
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,6 @@ class Product extends JobImport
314314
* @var CollectionFactory $categoryCollectionFactory
315315
*/
316316
protected $categoryCollectionFactory;
317-
/**
318-
* The default name value when empty
319-
*
320-
* @var ?array $defaultNameValue
321-
*/
322-
protected $defaultNameValue = null;
323317

324318
/**
325319
* Product constructor.
@@ -784,8 +778,6 @@ public function insertData()
784778
}
785779
}
786780

787-
$product = $this->handleNoName($product);
788-
789781
/** @var bool $result */
790782
$result = $this->entitiesHelper->insertDataFromApi(
791783
$product,
@@ -2457,6 +2449,8 @@ public function setValues()
24572449
);
24582450
}
24592451

2452+
$this->handleNoName();
2453+
24602454
if ($this->configHelper->isAdvancedLogActivated()) {
24612455
$this->logImportedEntities($this->logger, true, 'identifier');
24622456
}
@@ -5132,29 +5126,28 @@ private function updateProductVisibility(string $tmpTable, array $mappings): arr
51325126
}
51335127

51345128
/**
5135-
* If product has no name in Akeneo, give it an empty string name
5129+
* Set default product name for default if empty
51365130
*/
5137-
protected function handleNoName(array $product): array
5131+
protected function handleNoName(): void
51385132
{
5139-
if (array_key_exists(ProductInterface::NAME, $product['values'])) {
5140-
return $product;
5141-
}
5133+
$connection = $this->entitiesHelper->getConnection();
51425134

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;
51545142
}
51555143

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');
51575147

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`');
51595152
}
51605153
}

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"nyholm/psr7": "^1.5"
1515
},
1616
"type": "magento2-module",
17-
"version": "104.3.7",
17+
"version": "104.3.8",
1818
"license": [
1919
"OSL-3.0",
2020
"AFL-3.0"

0 commit comments

Comments
 (0)