Skip to content

Commit

Permalink
Merge pull request #86 from akeneo/release/100.2.6
Browse files Browse the repository at this point in the history
Release/100.2.6
  • Loading branch information
Dnd-Gimix authored Nov 20, 2019
2 parents b215488 + ed21f2a commit f54d538
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
**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
32 changes: 32 additions & 0 deletions Job/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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']]);
}
}
}

/**
Expand Down
31 changes: 31 additions & 0 deletions Job/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 4 additions & 1 deletion Job/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1542,7 +1545,7 @@ public function setRelated()
/* 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 */
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.5",
"version": "100.2.6",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down

0 comments on commit f54d538

Please sign in to comment.