From 751ba974c9cdf9b31d70c07db08cc4916e6b8940 Mon Sep 17 00:00:00 2001 From: Mathieu Fernandez Date: Wed, 11 Sep 2019 10:27:59 +0200 Subject: [PATCH 1/7] all: fix duplicated config.xml node leading to errors in product import and on backend category view --- etc/config.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/etc/config.xml b/etc/config.xml index 414044dc..75f068c3 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -24,13 +24,11 @@ = 100 1 + SINCE LAST N DAYS 1 - - SINCE LAST N DAYS - 1 1 From 9fe20cd66c6bd0b834a355a7fea3053a8828de5f Mon Sep 17 00:00:00 2001 From: Mathieu Fernandez Date: Fri, 4 Oct 2019 14:26:14 +0200 Subject: [PATCH 2/7] all: change temporary table column "identifier" datatype from VARBINARY to VARCHAR to be able to use classic string function on it (like LOWER) and to avoid having same value with different case in this column when table collation is "case-insensitive" --- Helper/Import/Entities.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Helper/Import/Entities.php b/Helper/Import/Entities.php index a510024d..a6d4051c 100644 --- a/Helper/Import/Entities.php +++ b/Helper/Import/Entities.php @@ -212,7 +212,7 @@ private function createTmpTable($fields, $tableSuffix) $table->addColumn( 'identifier', - Table::TYPE_VARBINARY, + Table::TYPE_TEXT, 255, [], 'identifier' From 668ca0155e830871624112181db5fa903069a6c8 Mon Sep 17 00:00:00 2001 From: Andreas Penz Date: Wed, 9 Oct 2019 13:16:02 +0200 Subject: [PATCH 3/7] website-mapping: change deleteSelect query to prevent deleting all present product to website associations if website attribute is specified --- Job/Product.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Job/Product.php b/Job/Product.php index fd0937a9..20f3d1ed 100644 --- a/Job/Product.php +++ b/Job/Product.php @@ -1256,11 +1256,8 @@ public function setWebsites() if ($associatedWebsites != null) { /** @var Select $deleteSelect */ $deleteSelect = $connection->select()->from( - $this->entitiesHelper->getTable('catalog_product_website'), - [ - 'product_id' => new Expr($row['entity_id']), - ] - ); + $this->entitiesHelper->getTable('catalog_product_website') + )->where('product_id = ?', $row['entity_id']); $connection->query( $connection->deleteFromSelect( From 8e02d174a19ca6a2357936d5d0be07a81fead9f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verri=C3=A8re?= Date: Wed, 9 Oct 2019 17:20:16 +0200 Subject: [PATCH 4/7] families-name: Add check on family label to prevent error on duplicate label --- Job/Family.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Job/Family.php b/Job/Family.php index d5480cfe..477fc477 100644 --- a/Job/Family.php +++ b/Job/Family.php @@ -195,6 +195,43 @@ public function insertFamilies() /** @var string $productEntityTypeId */ $productEntityTypeId = $this->eavConfig->getEntityType(ProductAttributeInterface::ENTITY_TYPE_CODE) ->getEntityTypeId(); + + /** @var array $values */ + $attributeToSelect = [ + 'attribute_set_name' => new Expr('CONCAT("Pim", " ", `' . $label . '`)'), + 'family_code' => 'code' + ]; + + /** @var Select $families */ + $tmpFamilyNames = $connection->select()->from($tmpTable, $attributeToSelect); + + /** @var \Zend_Db_Statement_Interface $query */ + $query = $connection->query($tmpFamilyNames); + + /** @var array $familyNames */ + $familyNames = []; + + /** @var array $row */ + while (($row = $query->fetch())) { + /** @var string $familyName */ + $familyName = $row['attribute_set_name']; + + if (in_array($familyName, $familyNames)) { + /** @var string $familyCode */ + $familyCode = $row['family_code']; + + $connection->delete($tmpTable, ['code = ?' => $familyCode]); + + $this->setAdditionalMessage( + __('Family with code "%1" has the same label than another family in Akeneo and has been skipped from import', $familyCode) + ); + + continue; + } + + $familyNames[] = $familyName; + } + /** @var array $values */ $values = [ 'attribute_set_id' => '_entity_id', From 67bae5b7dd694d8fcebc9920241c9a9f1440ee14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verri=C3=A8re?= Date: Thu, 10 Oct 2019 16:54:05 +0200 Subject: [PATCH 5/7] release100.2.3: Fix product website request if attribute is not filled in Akeneo --- Job/Product.php | 123 +++++++++++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/Job/Product.php b/Job/Product.php index 20f3d1ed..de80ae51 100644 --- a/Job/Product.php +++ b/Job/Product.php @@ -1238,73 +1238,76 @@ public function setWebsites() } } } - /** @var \Magento\Framework\DB\Select $select */ - $select = $connection->select()->from( - $tmpTable, - [ - 'entity_id' => '_entity_id', - 'identifier' => 'identifier', - 'associated_website' => $websiteAttribute, - ] - ); - /** @var \Magento\Framework\DB\Statement\Pdo\Mysql $query */ - $query = $connection->query($select); - /** @var array $row */ - while (($row = $query->fetch())) { - /** @var string[] $associatedWebsites */ - $associatedWebsites = $row['associated_website']; - if ($associatedWebsites != null) { - /** @var Select $deleteSelect */ - $deleteSelect = $connection->select()->from( - $this->entitiesHelper->getTable('catalog_product_website') - )->where('product_id = ?', $row['entity_id']); - - $connection->query( - $connection->deleteFromSelect( - $deleteSelect, + + if ($connection->tableColumnExists($tmpTable, $websiteAttribute)) { + /** @var \Magento\Framework\DB\Select $select */ + $select = $connection->select()->from( + $tmpTable, + [ + 'entity_id' => '_entity_id', + 'identifier' => 'identifier', + 'associated_website' => $websiteAttribute, + ] + ); + /** @var \Magento\Framework\DB\Statement\Pdo\Mysql $query */ + $query = $connection->query($select); + /** @var array $row */ + while (($row = $query->fetch())) { + /** @var string[] $associatedWebsites */ + $associatedWebsites = $row['associated_website']; + if ($associatedWebsites != null) { + /** @var Select $deleteSelect */ + $deleteSelect = $connection->select()->from( $this->entitiesHelper->getTable('catalog_product_website') - ) - ); + )->where('product_id = ?', $row['entity_id']); - $associatedWebsites = explode(',', $associatedWebsites); - /** @var string $associatedWebsite */ - foreach ($associatedWebsites as $associatedWebsite) { - /** @var bool $websiteSet */ - $websiteSet = false; - /** - * @var string $optionId - * @var string $websiteId - */ - foreach ($optionMapping as $optionId => $websiteId) { - if ($associatedWebsite == $optionId) { - $websiteSet = true; - /** @var Select $insertSelect */ - $insertSelect = $connection->select()->from( - $tmpTable, - [ - 'product_id' => new Expr($row['entity_id']), - 'website_id' => new Expr($websiteId), - ] - ); + $connection->query( + $connection->deleteFromSelect( + $deleteSelect, + $this->entitiesHelper->getTable('catalog_product_website') + ) + ); - $connection->query( - $connection->insertFromSelect( - $insertSelect, - $this->entitiesHelper->getTable('catalog_product_website'), - ['product_id', 'website_id'], - AdapterInterface::INSERT_ON_DUPLICATE - ) - ); + $associatedWebsites = explode(',', $associatedWebsites); + /** @var string $associatedWebsite */ + foreach ($associatedWebsites as $associatedWebsite) { + /** @var bool $websiteSet */ + $websiteSet = false; + /** + * @var string $optionId + * @var string $websiteId + */ + foreach ($optionMapping as $optionId => $websiteId) { + if ($associatedWebsite == $optionId) { + $websiteSet = true; + /** @var Select $insertSelect */ + $insertSelect = $connection->select()->from( + $tmpTable, + [ + 'product_id' => new Expr($row['entity_id']), + 'website_id' => new Expr($websiteId), + ] + ); + + $connection->query( + $connection->insertFromSelect( + $insertSelect, + $this->entitiesHelper->getTable('catalog_product_website'), + ['product_id', 'website_id'], + AdapterInterface::INSERT_ON_DUPLICATE + ) + ); + } } - } - if ($websiteSet === false) { - $optionLabel = $attribute->getSource()->getOptionText($associatedWebsite); - $this->setAdditionalMessage(__('Warning: The product with Akeneo id %1 has an option (%2) that does not correspond to a Magento website.', $row['identifier'], $optionLabel)); + if ($websiteSet === false) { + $optionLabel = $attribute->getSource()->getOptionText($associatedWebsite); + $this->setAdditionalMessage(__('Warning: The product with Akeneo id %1 has an option (%2) that does not correspond to a Magento website.', $row['identifier'], $optionLabel)); + } } + } else { + $this->setAdditionalMessage( __('Warning: The product with Akeneo id %1 has no associated website in the custom attribute.', $row['identifier'])); } - } else { - $this->setAdditionalMessage( __('Warning: The product with Akeneo id %1 has no associated website in the custom attribute.', $row['identifier'])); } } } else { From 7e485ecd7d15bf33fccfdd4b718bcaceed6e7940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verri=C3=A8re?= Date: Thu, 10 Oct 2019 16:58:30 +0200 Subject: [PATCH 6/7] all: Add version 100.2.3 changelogs --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0e0daaa..a5b561ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,4 +15,11 @@ ### Version 100.2.2 : * Fix issue when importing associations -* Improve attribute option import \ No newline at end of file +* Improve attribute option import + +### Version 100.2.3 : +* Fix identifier column type in temporary product import table +* Fix missing where statement on delete in website association feature +* Fix product website request if attribute is not filled in Akeneo +* Fix duplicate node in config.xml file +* Add check on family label to prevent import error on duplicate labels in Akeneo \ No newline at end of file From 3df3672fbb35f3fbdca22de5e34e72d800c10e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verri=C3=A8re?= Date: Thu, 10 Oct 2019 16:59:30 +0200 Subject: [PATCH 7/7] all: Bump composer.json version to 100.2.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d623dba5..d48ec08d 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "php-http/guzzle6-adapter": "^1.1" }, "type": "magento2-module", - "version": "100.2.2", + "version": "100.2.3", "license": [ "OSL-3.0", "AFL-3.0"