diff --git a/CHANGELOG.md b/CHANGELOG.md index eec538cf..b236280c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -514,3 +514,12 @@ * PGTO-340: Fix job executor date format * PGTO-462: Set attribute code to lowercase for options * Fix non-scopable localizable attribute import + +### Version 104.3.15 : +* PGTO-398: Do not create an empty value for visual swatch in stores +* PGTO-463: Fix empty option label error for table attributes +* PGTO-472: Empty product model option label if not exist for local +* PGTO-479: Fix UUID error when product models have no variant +* PGTO-480: Fix request to match existing options +* Set default product name to empty instead of null +* Update UUID according sku configured column diff --git a/Helper/Import/Option.php b/Helper/Import/Option.php index 047d3800..4097929f 100644 --- a/Helper/Import/Option.php +++ b/Helper/Import/Option.php @@ -98,7 +98,7 @@ public function matchEntity($pimKey, $entityTable, $entityKey, $import, $prefix ['a' => $this->getTable('eav_attribute')], 'o.`attribute_id` = a.`attribute_id` AND t.`attribute` = a.`attribute_code`', [] - )->where('e.store_id = ?', 0)->where('a.entity_type_id', $entityTypeId); + )->where('e.store_id = ?', 0)->where('a.entity_type_id = ?', $entityTypeId); /** @var string[] $existingMagentoOptions */ $existingMagentoOptions = $connection->query($select)->fetchAll(); /** @var string[] $existingMagentoOptionIds */ diff --git a/Helper/ProductModel.php b/Helper/ProductModel.php index 832cec4c..08ccfcd2 100644 --- a/Helper/ProductModel.php +++ b/Helper/ProductModel.php @@ -283,7 +283,7 @@ public function insertData(AkeneoPimClientInterface $akeneoClient, array $filter /** @var string[][] $option */ foreach ($config['options'] as $option) { if ($option['code'] === $newData || $option['code'] === $label) { - $table['data'][$i][$label] = [$newLabel => $option['labels'][$locale]]; + $table['data'][$i][$label] = [$newLabel => $option['labels'][$locale] ?? '']; } } } @@ -441,7 +441,7 @@ public function getMetricsSymbols($akeneoClient) * * @param string $code * @param string|null $family - * + * * @return void */ public function addColumns($code, ?string $family = null) diff --git a/Job/Option.php b/Job/Option.php index 81a3dada..824715d5 100644 --- a/Job/Option.php +++ b/Job/Option.php @@ -557,6 +557,11 @@ public function insertSwatchOption(): void foreach ($swatchesAttributesData as $swatchesAttributeData) { $optionTypeAndValue = $this->getTypeAndValue($swatchesAttributes, $swatchesAttributeData); + if ((int)$optionTypeAndValue['type'] === Swatch::SWATCH_TYPE_VISUAL_IMAGE && + (int)$swatchesAttributeData['store_id'] !== 0) + { + continue; + } $dataToInsert[] = [ 'option_id' => $swatchesAttributeData['option_id'], 'store_id' => $swatchesAttributeData['store_id'], @@ -597,8 +602,9 @@ public function getTypeAndValue(array $swatchesAttributes, array $swatchesAttrib $current = $connection->fetchRow( $connection->select() ->from($this->entitiesHelper->getTable('eav_attribute_option_swatch'), ['value', 'type']) - ->where('store_id = ?', $swatchesAttributeData['store_id']) + ->where('store_id = 0 OR store_id = ?', $swatchesAttributeData['store_id']) ->where('option_id = ?', $swatchesAttributeData['option_id']) + ->order('store_id DESC') ->limit(1) ); if (!empty($current)) { diff --git a/Job/Product.php b/Job/Product.php index ceb068a1..c759335a 100644 --- a/Job/Product.php +++ b/Job/Product.php @@ -605,8 +605,6 @@ public function createTable() __('No product found for family: %1 but product model found, process with import', $family), $this->logger ); - - return; } else { $product = reset($products); // Make sure to delete product model table @@ -621,17 +619,20 @@ public function createTable() if ($this->entitiesHelper->isProductUuidEdition()) { $tmpTable = $this->entitiesHelper->getTableName($this->jobExecutor->getCurrentJob()->getCode()); - $connection->changeColumn( - $tmpTable, - 'uuid', - 'uuid', - [ - 'nullable' => true, - 'type' => Table::TYPE_TEXT, - 'length' => 255, - 'comment' => 'UUID', - ] - ); + $definition = [ + 'nullable' => true, + 'type' => Table::TYPE_TEXT, + 'length' => 255, + 'comment' => 'UUID', + ]; + + if ($connection->tableColumnExists($tmpTable, 'uuid')) { + $connection->changeColumn($tmpTable, 'uuid', 'uuid', $definition); + } else { + // We have no product (like product models without variant) with applied filters + // We need to add manually the column + $connection->addColumn($tmpTable, 'uuid', $definition); + } $connection->addIndex($tmpTable, 'UNIQUE_UUID', 'uuid', 'unique'); } } @@ -752,7 +753,7 @@ public function insertData() /** @var string[][] $option */ foreach ($config['options'] as $option) { if ($option['code'] === $newData || $option['code'] === $label) { - $table['data'][$i][$label] = [$newLabel => $option['labels'][$locale]]; + $table['data'][$i][$label] = [$newLabel => $option['labels'][$locale] ?? '']; } } } @@ -1725,12 +1726,14 @@ public function matchEntities() return; } - if ($this->entitiesHelper->isProductUuidEdition() && $connection->tableColumnExists($tmpTable, 'sku')) { - // We replace the sku by the uuid in the Akeneo entities table if needed for retro-compatibility + $skuColumn = $this->configHelper->getAkeneoAttributeCodeForSku() ?: 'sku'; + + if ($this->entitiesHelper->isProductUuidEdition() && $connection->tableColumnExists($tmpTable, $skuColumn)) { + // We replace the sku by the uuid in the Akeneo entities table if needed $entitiesTable = $this->entitiesHelper->getTable('akeneo_connector_entities'); $uuids = $connection->select() ->from(false, ['code' => 'tmp.uuid']) - ->joinInner(['tmp' => $tmpTable], '`tmp`.`sku` = `ace`.`code`', []) + ->joinInner(['tmp' => $tmpTable], '`tmp`.`' . $skuColumn . '` = `ace`.`code`', []) ->where('`ace`.`import` = ?', 'product'); $connection->query($connection->updateFromSelect($uuids, ['ace' => $entitiesTable])); } @@ -5188,7 +5191,7 @@ protected function handleNoName(): void $connection->query('INSERT IGNORE INTO `' . $entityVarcharTable . '` (`attribute_id`, `store_id`, `value`, `' . $columnIdentifier . '`) - SELECT ' . $attribute->getId() . ', 0, NULL, `' . $columnIdentifier . '` FROM `' . $entityTable . '` e + SELECT ' . $attribute->getId() . ', 0, "", `' . $columnIdentifier . '` FROM `' . $entityTable . '` e INNER JOIN `' . $tmpTable . '` t ON e.`entity_id` = t.`_entity_id`'); } } diff --git a/composer.json b/composer.json index 41173aaf..8bf69715 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "nyholm/psr7": "^1.5" }, "type": "magento2-module", - "version": "104.3.14", + "version": "104.3.15", "license": [ "OSL-3.0", "AFL-3.0"