Skip to content

Commit

Permalink
Merge pull request #48 from akeneo/release/100.2.3
Browse files Browse the repository at this point in the history
Release/100.2.3
  • Loading branch information
Dnd-Gimix authored Oct 10, 2019
2 parents 9edbe8f + 3df3672 commit 98fb417
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 68 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@

### Version 100.2.2 :
* Fix issue when importing associations
* Improve attribute option import
* 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
2 changes: 1 addition & 1 deletion Helper/Import/Entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private function createTmpTable($fields, $tableSuffix)

$table->addColumn(
'identifier',
Table::TYPE_VARBINARY,
Table::TYPE_TEXT,
255,
[],
'identifier'
Expand Down
37 changes: 37 additions & 0 deletions Job/Family.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
124 changes: 62 additions & 62 deletions Job/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -1238,76 +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'),
[
'product_id' => new Expr($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 {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
<completeness_type>=</completeness_type>
<completeness_value>100</completeness_value>
<status>1</status>
<updated_mode>SINCE LAST N DAYS</updated_mode>
</products_filters>
<product>
<url_generation_enabled>1</url_generation_enabled>
</product>
<products_filters>
<updated_mode>SINCE LAST N DAYS</updated_mode>
</products_filters>
<category>
<is_active>1</is_active>
<include_in_menu>1</include_in_menu>
Expand Down

0 comments on commit 98fb417

Please sign in to comment.