Skip to content

Commit

Permalink
Merge pull request #697 from akeneo/release/104.3.9
Browse files Browse the repository at this point in the history
Release/104.3.9
  • Loading branch information
magentix authored Jun 26, 2024
2 parents 80de21f + 7027353 commit 9fa9747
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,9 @@

### Version 104.3.8 :
* PGTO-433: Product default name logic

### Version 104.3.9 :
* Adds a config option to disable InnoDB Strict Mode in the session
* Only remove products from categories managed in Akeneo
* Optimize media import
* Only fill completeness when we have products
12 changes: 11 additions & 1 deletion Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Akeneo\Connector\Helper;

use Akeneo\Connector\Model\Source\Engine as EngineSourceModel;
use Exception;
use Magento\Catalog\Helper\Product as ProductHelper;
use Magento\Catalog\Model\Product\Link;
Expand Down Expand Up @@ -567,6 +568,10 @@ class Config
* Storage engine to use with temporary tables
*/
protected const TABLE_STORAGE_ENGINE = 'akeneo_connector/akeneo_api/storage_engine';
/**
* Flag to disable InnoDB Strict Mode in mysql connections
*/
private const CONNECTION_DISABLE_INNODB_STRICT_MODE = 'akeneo_connector/akeneo_api/disable_innodb_strict_mode';

/**
* This variable contains a Encryptor
Expand Down Expand Up @@ -1337,7 +1342,7 @@ public function getProductTaxClasses()
*/
public function getDefaultWebsiteId()
{
return $this->storeManager->getStore()->getWebsiteId();
return $this->storeManager->getDefaultStoreView()->getWebsiteId();
}

/**
Expand Down Expand Up @@ -2027,4 +2032,9 @@ public function getStorageEngine(): string
return (string)$this->scopeConfig->getValue(self::TABLE_STORAGE_ENGINE);
}

public function getShouldDisabledInnoDBStrictMode(): bool
{
return (bool) $this->scopeConfig->getValue(self::CONNECTION_DISABLE_INNODB_STRICT_MODE)
&& $this->getStorageEngine() === EngineSourceModel::STORAGE_ENGINE_INNODB;
}
}
5 changes: 5 additions & 0 deletions Helper/Import/Entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ public function __construct(
*/
public function getConnection()
{
if ($this->configHelper->getShouldDisabledInnoDBStrictMode()) {
$this->connection->query('SET SESSION innodb_strict_mode = 0');
}

return $this->connection;
}

Expand Down Expand Up @@ -297,6 +301,7 @@ public function createTmpTable(array $fields, string $tableSuffix, ?string $fami
);

if ($this->configHelper->getStorageEngine() === Engine::STORAGE_ENGINE_INNODB) {
$table->setOption('type', 'InnoDB');
$table->setOption('row_format', 'dynamic');
} else {
$table->setOption('type', 'MYISAM');
Expand Down
2 changes: 1 addition & 1 deletion Helper/Import/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public function formatCompleteness(array $values, ?string $assoKey = null)
}
}

if (isset($finalProducts)) {
if (!empty($finalProducts)) {
$completeness['completenesses_' . $product['scope']] = $this->jsonSerializer->serialize($finalProducts);
}

Expand Down
2 changes: 1 addition & 1 deletion Job/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,6 @@ public function createEntities()
'path' => 'path',
'position' => 'position',
'level' => 'level',
'children_count' => new Expr('0'),
];

/** @var Select $parents */
Expand All @@ -621,6 +620,7 @@ public function createEntities()
/** @var array $values */
$values = [
'created_at' => new Expr('now()'),
'children_count' => new Expr('0'),
];
$connection->update($table, $values, 'created_at IS NULL');

Expand Down
10 changes: 6 additions & 4 deletions Job/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -3043,10 +3043,11 @@ public function setCategories(): void
$virtualCategories = [0];
}
$virtualCategories = join(',', $virtualCategories);
$managedCategories = implode(',', array_values(array_map(fn($category) => $category['entity_id'], $categoryAkeneo)));

$connection->delete(
$categoryProductTable,
new \Zend_Db_Expr("product_id IN ($productIds) AND category_id NOT IN ($virtualCategories) AND (product_id, category_id) NOT IN ($productCategoryExclusion)")
new \Zend_Db_Expr("product_id IN ($productIds) AND category_id NOT IN ($virtualCategories) AND category_id IN ($managedCategories) AND (product_id, category_id) NOT IN ($productCategoryExclusion)")
);
}
}
Expand Down Expand Up @@ -3995,6 +3996,10 @@ public function importMedia(): void
$dataToImport = [];
/** @var bool $valueFound */
$valueFound = false;

/** @var array $columns */
$columns = $this->configHelper->getMediaImportImagesColumns();

foreach ($gallery as $image) {
if (!$connection->tableColumnExists($tmpTable, strtolower($image))) {
// If not exist, check for each store if the field exist
Expand Down Expand Up @@ -4213,9 +4218,6 @@ public function importMedia(): void
}
$connection->insertOnDuplicate($galleryValueTable, $data, array_keys($data));

/** @var array $columns */
$columns = $this->configHelper->getMediaImportImagesColumns();

foreach ($columns as $column) {
/** @var string $columnName */
$columnName = $column['column'];
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"nyholm/psr7": "^1.5"
},
"type": "magento2-module",
"version": "104.3.8",
"version": "104.3.9",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
8 changes: 8 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@
<source_model>Akeneo\Connector\Model\Source\Engine</source_model>
<comment>Storage engine to use for temporary tables. MyISAM allows high scalability, with important number of attributes. InnoDB is recommended but may cause errors during import for a large catalog.</comment>
</field>
<field id="disable_innodb_strict_mode" translate="label comment" type="select" sortOrder="110" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Disable InnoDB Strict Mode</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>When not possible to use MyISAM, we can disable InnoDB Strict Mode in the session of mysql connections that this module uses. This can also solve imports for catalogs with many attributes.</comment>
<depends>
<field id="storage_engine">innodb</field>
</depends>
</field>
</group>
<group id="products_filters" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Filter Products</label>
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<pagination_size>100</pagination_size>
<edition>less_four_point_zero_point_sixty_two</edition>
<storage_engine>myisam</storage_engine>
<disable_innodb_strict_mode>0</disable_innodb_strict_mode>
</akeneo_api>
<products_filters>
<mode>standard</mode>
Expand Down

0 comments on commit 9fa9747

Please sign in to comment.