From 015e837bbf11715c7160aa84e1bc07bdb34330f3 Mon Sep 17 00:00:00 2001 From: Rodrigue Millard Date: Tue, 12 Nov 2019 17:49:05 +0100 Subject: [PATCH 1/6] option-verification: Don't import options without admin store language label --- Job/Option.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Job/Option.php b/Job/Option.php index 5424f1cb..aea1fb16 100644 --- a/Job/Option.php +++ b/Job/Option.php @@ -230,6 +230,37 @@ public function insertOptions() $connection = $this->entitiesHelper->getConnection(); /** @var string $tmpTable */ $tmpTable = $this->entitiesHelper->getTableName($this->getCode()); + + /* Remove option without a admin store label */ + /** @var string $localeCode */ + $localeCode = $this->configHelper->getDefaultLocale(); + /** @var \Magento\Framework\DB\Select $select */ + $select = $connection->select()->from( + $tmpTable, + [ + 'entity_id' => '_entity_id', + 'label' => 'labels-' . $localeCode, + 'code' => 'code', + 'attribute' => 'attribute', + ] + )->where('`labels-' . $localeCode . '` IS NULL'); + /** @var \Zend_Db_Statement_Interface $query */ + $query = $connection->query($select); + /** @var array $row */ + while (($row = $query->fetch())) { + if (!isset($row['label']) || $row['label'] === null) { + $connection->delete($tmpTable, ['_entity_id = ?' => $row['entity_id']]); + $this->setAdditionalMessage( + __( + 'The option %1 from attribute %2 was not imported because it did not have a translation in admin store language : %3', + $row['code'], + $row['attribute'], + $localeCode + ) + ); + } + } + /** @var array $columns */ $columns = [ 'option_id' => 'a._entity_id', From f8c033303c15afcf28f246c503bea2b94ffecd13 Mon Sep 17 00:00:00 2001 From: Rodrigue Millard Date: Wed, 13 Nov 2019 15:46:02 +0100 Subject: [PATCH 2/6] attribute-verification: Don't import attributes without admin store language label --- Job/Attribute.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Job/Attribute.php b/Job/Attribute.php index 83f5ad1c..ce2e1868 100644 --- a/Job/Attribute.php +++ b/Job/Attribute.php @@ -154,6 +154,10 @@ public function createTable() */ public function insertData() { + /** @var AdapterInterface $connection */ + $connection = $this->entitiesHelper->getConnection(); + /** @var string $tmpTable */ + $tmpTable = $this->entitiesHelper->getTableName($this->getCode()); /** @var string|int $paginationSize */ $paginationSize = $this->configHelper->getPanigationSize(); /** @var ResourceCursorInterface $attributes */ @@ -173,6 +177,34 @@ public function insertData() $this->setMessage( __('%1 line(s) found', $index) ); + + /* Remove attribute without a admin store label */ + /** @var string $localeCode */ + $localeCode = $this->configHelper->getDefaultLocale(); + /** @var \Magento\Framework\DB\Select $select */ + $select = $connection->select()->from( + $tmpTable, + [ + 'label' => 'labels-' . $localeCode, + 'code' => 'code', + ] + )->where('`labels-' . $localeCode . '` IS NULL'); + + /** @var \Zend_Db_Statement_Interface $query */ + $query = $connection->query($select); + /** @var array $row */ + while (($row = $query->fetch())) { + if (!isset($row['label']) || $row['label'] === null) { + $this->setAdditionalMessage( + __( + 'The attribute %1 was not imported because it did not have a translation in admin store language : %2', + $row['code'], + $localeCode + ) + ); + $connection->delete($tmpTable, ['code = ?' => $row['code']]); + } + } } /** From 71e2d22dc9aa592ab8446cb2e07180f3c5985dfa Mon Sep 17 00:00:00 2001 From: Rodrigue Millard Date: Tue, 19 Nov 2019 16:30:58 +0100 Subject: [PATCH 3/6] product-associations-conservation: Don't delete the associations of filtered products --- Job/Product.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Job/Product.php b/Job/Product.php index 735d73dd..3419da31 100644 --- a/Job/Product.php +++ b/Job/Product.php @@ -1538,11 +1538,11 @@ public function setRelated() 'link_type_id' => new Expr($typeId), ] )->joinInner(['e' => $productsTable], sprintf('c.entity_id = e.%s', $columnIdentifier), []); - + $productIds = $connection->select()->from($tmpTable, ['product_id' => '_entity_id']); /* Remove old link */ $connection->delete( $linkTable, - ['(product_id, linked_product_id, link_type_id) NOT IN (?)' => $select, 'link_type_id = ?' => $typeId] + ['(product_id, linked_product_id, link_type_id) NOT IN (?)' => $select, 'link_type_id = ?' => $typeId, 'product_id IN (?)' => $productIds] ); /* Insert new link */ From 199991cf71360938cb944ea07418580eb205aa23 Mon Sep 17 00:00:00 2001 From: Rodrigue Millard Date: Wed, 20 Nov 2019 10:56:04 +0100 Subject: [PATCH 4/6] product-associations-conservation: Move select out of foreach --- Job/Product.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Job/Product.php b/Job/Product.php index 3419da31..91c405c9 100644 --- a/Job/Product.php +++ b/Job/Product.php @@ -1521,6 +1521,9 @@ public function setRelated() } } + /** @var \Magento\Framework\DB\Select $productIds */ + $productIds = $connection->select()->from($tmpTable, ['product_id' => '_entity_id']); + /** * @var int $typeId * @var string[] $columns @@ -1538,7 +1541,7 @@ public function setRelated() 'link_type_id' => new Expr($typeId), ] )->joinInner(['e' => $productsTable], sprintf('c.entity_id = e.%s', $columnIdentifier), []); - $productIds = $connection->select()->from($tmpTable, ['product_id' => '_entity_id']); + /* Remove old link */ $connection->delete( $linkTable, From a99c973e8b732da9798b2cca6f5cf0eea85a4302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verri=C3=A8re?= Date: Wed, 20 Nov 2019 12:00:50 +0100 Subject: [PATCH 5/6] all: Add version 100.2.6 changelogs --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcf05e14..fda26313 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,4 +32,8 @@ ### Version 100.2.5 : * Improve configurable attributes feature with specific types -**Warning :** *After updating connector to this version, please check the `Configurable` configuration under the `Products` section in the Akeneo Connector configuration and update the `Type` column of your mapping with the appropriate value if necessary.* \ No newline at end of file +**Warning :** *After updating connector to this version, please check the `Configurable` configuration under the `Products` section in the Akeneo Connector configuration and update the `Type` column of your mapping with the appropriate value if necessary.* + +### Version 100.2.6 : +* Add check to prevent the creation of attributes and options with empty admin label +* Fix product association deletion with differential product import \ No newline at end of file From ed21f2a5015f0294e00f77510c1f33ad2467ba73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verri=C3=A8re?= Date: Wed, 20 Nov 2019 12:02:14 +0100 Subject: [PATCH 6/6] all: Bump composer version to 100.2.6 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8a18c799..dfce0721 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "php-http/guzzle6-adapter": "^1.1" }, "type": "magento2-module", - "version": "100.2.5", + "version": "100.2.6", "license": [ "OSL-3.0", "AFL-3.0"