diff --git a/CHANGELOG.md b/CHANGELOG.md
index 254640e5..d2a16fb9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -42,4 +42,13 @@
* Remove Akeneo attribute group import from connector (https://help.akeneo.com/magento2-connector/v100/articles/where-attributes.html#where-to-find-my-attribute-groups-in-magento-2)
* Remove automatic mapping for attributes "price", "special_price" and "cost" (https://help.akeneo.com/magento2-connector/v100/articles/what-data.html#attribute-types)
* Add metric as product variant and unit concatenation feature (https://help.akeneo.com/magento2-connector/v100/articles/05-configure-products.html#metric-attributes)
-* Update wording for configurable product attribute mapping
\ No newline at end of file
+* Update wording for configurable product attribute mapping
+
+### Version 100.3.1 :
+* Fix product image name that should not exceed 90 characters since Magento 2.3.3
+
+**Warning :** *After updating connector to this version, all image names will be renamed. To know more, please consult documentation (https://help.akeneo.com/magento2-connector/v100/articles/06-import-images-configuration.html)*
+
+* Remove unused "file" column on log grid
+* Move API client call from construct
+* Fix category URL issue adding -1, -2 to url-key when category had same name but not same parent category
\ No newline at end of file
diff --git a/Helper/Import/Entities.php b/Helper/Import/Entities.php
index a6d4051c..511fffbb 100644
--- a/Helper/Import/Entities.php
+++ b/Helper/Import/Entities.php
@@ -762,4 +762,34 @@ public function formatUrlKeyColumn($tmpTable, $local = null) {
}
}
}
+
+ /**
+ * Format media filename, removing hash and stoppig at 90 characters
+ *
+ * @param string $filename
+ *
+ * @return string
+ */
+ public function formatMediaName($filename)
+ {
+ /** @var string[] $filenameParts */
+ $filenameParts = explode('.', $filename);
+ // Get the extention
+ /** @var string $extension */
+ $extension = array_pop($filenameParts);
+ // Get the hash
+ $filename = implode('.', $filenameParts);
+ $filename = explode('_', $filename);
+ /** @var string $shortHash */
+ $shortHash = array_shift($filename);
+ $shortHash = substr($shortHash, 0, 4);
+ $filename = implode('_', $filename);
+ // Form the final file name
+ /** @var string $shortName */
+ $shortName = substr($filename, 0, 79);
+ /** @var string $finalName */
+ $finalName = $shortName . '_' . $shortHash . '.' . $extension;
+
+ return $finalName;
+ }
}
diff --git a/Job/Category.php b/Job/Category.php
index 1b6c7481..b50642bf 100755
--- a/Job/Category.php
+++ b/Job/Category.php
@@ -186,6 +186,62 @@ public function matchEntities()
);
}
+ /**
+ * Set Categories structure
+ *
+ * @return void
+ */
+ public function setStructure()
+ {
+ /** @var AdapterInterface $connection */
+ $connection = $this->entitiesHelper->getConnection();
+ /** @var string $tableName */
+ $tmpTable = $this->entitiesHelper->getTableName($this->getCode());
+
+ $connection->addColumn($tmpTable, 'level', [
+ 'type' => 'integer',
+ 'length' => 11,
+ 'default' => 0,
+ 'COMMENT' => ' ',
+ 'nullable' => false
+ ]);
+ $connection->addColumn($tmpTable, 'path', [
+ 'type' => 'text',
+ 'length' => 255,
+ 'default' => '',
+ 'COMMENT' => ' ',
+ 'nullable' => false
+ ]);
+ $connection->addColumn($tmpTable, 'parent_id', [
+ 'type' => 'integer',
+ 'length' => 11,
+ 'default' => 0,
+ 'COMMENT' => ' ',
+ 'nullable' => false
+ ]);
+
+ /** @var array $values */
+ $values = [
+ 'level' => 1,
+ 'path' => new Expr('CONCAT(1, "/", `_entity_id`)'),
+ 'parent_id' => 1,
+ ];
+ $connection->update($tmpTable, $values, 'parent IS NULL');
+
+ /** @var int $depth */
+ $depth = self::MAX_DEPTH;
+ for ($i = 1; $i <= $depth; $i++) {
+ $connection->query('
+ UPDATE `' . $tmpTable . '` c1
+ INNER JOIN `' . $tmpTable . '` c2 ON c2.`code` = c1.`parent`
+ SET c1.`level` = c2.`level` + 1,
+ c1.`path` = CONCAT(c2.`path`, "/", c1.`_entity_id`),
+ c1.`parent_id` = c2.`_entity_id`
+ WHERE c1.`level` <= c2.`level` - 1
+ ');
+ }
+ }
+
/**
* Set categories Url Key
*
@@ -237,11 +293,11 @@ public function setUrlKey()
$finalKey = $urlKey;
/** @var int $increment */
$increment = 1;
- while (in_array($finalKey, $keys)) {
+ while (isset($keys[$row['parent_id']]) && in_array($finalKey, $keys[$row['parent_id']])) {
$finalKey = $urlKey . '-' . $increment++;
}
- $keys[] = $finalKey;
+ $keys[$row['parent_id']][] = $finalKey;
$connection->update(
$tmpTable,
@@ -253,62 +309,6 @@ public function setUrlKey()
}
}
- /**
- * Set Categories structure
- *
- * @return void
- */
- public function setStructure()
- {
- /** @var AdapterInterface $connection */
- $connection = $this->entitiesHelper->getConnection();
- /** @var string $tableName */
- $tmpTable = $this->entitiesHelper->getTableName($this->getCode());
-
- $connection->addColumn($tmpTable, 'level', [
- 'type' => 'integer',
- 'length' => 11,
- 'default' => 0,
- 'COMMENT' => ' ',
- 'nullable' => false
- ]);
- $connection->addColumn($tmpTable, 'path', [
- 'type' => 'text',
- 'length' => 255,
- 'default' => '',
- 'COMMENT' => ' ',
- 'nullable' => false
- ]);
- $connection->addColumn($tmpTable, 'parent_id', [
- 'type' => 'integer',
- 'length' => 11,
- 'default' => 0,
- 'COMMENT' => ' ',
- 'nullable' => false
- ]);
-
- /** @var array $values */
- $values = [
- 'level' => 1,
- 'path' => new Expr('CONCAT(1, "/", `_entity_id`)'),
- 'parent_id' => 1,
- ];
- $connection->update($tmpTable, $values, 'parent IS NULL');
-
- /** @var int $depth */
- $depth = self::MAX_DEPTH;
- for ($i = 1; $i <= $depth; $i++) {
- $connection->query('
- UPDATE `' . $tmpTable . '` c1
- INNER JOIN `' . $tmpTable . '` c2 ON c2.`code` = c1.`parent`
- SET c1.`level` = c2.`level` + 1,
- c1.`path` = CONCAT(c2.`path`, "/", c1.`_entity_id`),
- c1.`parent_id` = c2.`_entity_id`
- WHERE c1.`level` <= c2.`level` - 1
- ');
- }
- }
-
/**
* Set categories position
*
diff --git a/Job/Import.php b/Job/Import.php
index cc61c158..6dc108e4 100644
--- a/Job/Import.php
+++ b/Job/Import.php
@@ -64,6 +64,12 @@ abstract class Import extends DataObject implements ImportInterface
* @var OutputHelper $outputHelper
*/
protected $outputHelper;
+ /**
+ * This variable contains an Authenticator
+ *
+ * @var mixed $authenticator
+ */
+ protected $authenticator;
/**
* This variable contains a mixed value
*
@@ -117,11 +123,7 @@ public function __construct(
) {
parent::__construct($data);
- try {
- $this->akeneoClient = $authenticator->getAkeneoApiClient();
- } catch (\Exception $e) {
- $this->akeneoClient = false;
- }
+ $this->authenticator = $authenticator;
$this->outputHelper = $outputHelper;
$this->eventManager = $eventManager;
$this->step = 0;
@@ -426,6 +428,10 @@ public function execute()
return $this->outputHelper->getNoImportFoundResponse();
}
+ if (!$this->akeneoClient) {
+ $this->akeneoClient = $this->getAkeneoClient();
+ }
+
if (!$this->akeneoClient) {
return $this->outputHelper->getApiConnectionError();
}
@@ -595,4 +601,21 @@ public function checkLabelPerLocales(array $entity, array $lang, string $respons
}
return $response;
}
+
+ /**
+ * Get Akeneo Client instance
+ *
+ * @return AkeneoPimEnterpriseClientInterface|false
+ */
+ public function getAkeneoClient()
+ {
+ try {
+ /** @var AkeneoPimEnterpriseClientInterface|false $akeneoClient */
+ $akeneoClient = $this->authenticator->getAkeneoApiClient();
+ } catch (\Exception $e) {
+ $akeneoClient = false;
+ }
+
+ return $akeneoClient;
+ }
}
diff --git a/Job/Option.php b/Job/Option.php
index aea1fb16..a0211d25 100644
--- a/Job/Option.php
+++ b/Job/Option.php
@@ -156,6 +156,9 @@ public function createTable()
/** @var array $attribute */
foreach ($attributes as $attribute) {
if ($attribute['type'] == 'pim_catalog_multiselect' || $attribute['type'] == 'pim_catalog_simpleselect') {
+ if (!$this->akeneoClient) {
+ $this->akeneoClient = $this->getAkeneoClient();
+ }
/** @var PageInterface $options */
$options = $this->akeneoClient->getAttributeOptionApi()->listPerPage($attribute['code']);
if (empty($options->getItems())) {
@@ -377,6 +380,9 @@ public function cleanCache()
*/
protected function processAttributeOption($attributeCode, $paginationSize)
{
+ if (!$this->akeneoClient) {
+ $this->akeneoClient = $this->getAkeneoClient();
+ }
/** @var ResourceCursorInterface $options */
$options = $this->akeneoClient->getAttributeOptionApi()->all($attributeCode, $paginationSize);
/** @var int $index */
@@ -398,6 +404,9 @@ protected function processAttributeOption($attributeCode, $paginationSize)
public function getAllAttributes()
{
if (!$this->attributes) {
+ if (!$this->akeneoClient) {
+ $this->akeneoClient = $this->getAkeneoClient();
+ }
$this->attributes = $this->akeneoClient->getAttributeApi()->all();
}
diff --git a/Job/Product.php b/Job/Product.php
index e7e3e23b..e03a6e35 100644
--- a/Job/Product.php
+++ b/Job/Product.php
@@ -2063,7 +2063,7 @@ public function importMedia()
/** @var array $media */
$media = $this->akeneoClient->getProductMediaFileApi()->get($row[$image]);
/** @var string $name */
- $name = basename($media['code']);
+ $name = $this->entitiesHelper->formatMediaName(basename($media['code']));
if (!$this->configHelper->mediaFileExists($name)) {
$binary = $this->akeneoClient->getProductMediaFileApi()->download($row[$image]);
diff --git a/composer.json b/composer.json
index 7f81a779..048debe3 100644
--- a/composer.json
+++ b/composer.json
@@ -11,7 +11,7 @@
"php-http/guzzle6-adapter": "^1.1"
},
"type": "magento2-module",
- "version": "100.3.0",
+ "version": "100.3.1",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/etc/di.xml b/etc/di.xml
index a839f70c..9c15e4cb 100755
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -44,13 +44,13 @@
- Match code with Magento ID
-
-
- setUrlKey
- - Create URL key
-
- -
- setStructure
- Create structure
+ -
+
- setUrlKey
+ - Create URL key
+
-
- removeCategoriesByFilter
- Remove Categories By Filter
diff --git a/view/adminhtml/layout/akeneo_connector_log_index.xml b/view/adminhtml/layout/akeneo_connector_log_index.xml
index 1188b85b..b2d89647 100644
--- a/view/adminhtml/layout/akeneo_connector_log_index.xml
+++ b/view/adminhtml/layout/akeneo_connector_log_index.xml
@@ -62,12 +62,6 @@
name
-
-
- File
- file
-
-
Status