Skip to content

Commit

Permalink
Merge pull request #671 from akeneo/release/104.3.1
Browse files Browse the repository at this point in the history
Release/104.3.1
  • Loading branch information
magentix authored Dec 29, 2023
2 parents 685bd65 + 97baff4 commit c751341
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,6 @@

### Version 104.0.7 :
* PGTO-397: Never delete products in a virtual category

### Version 104.3.1 :
* PGTO-402: Fix admin default value empty name
25 changes: 22 additions & 3 deletions Job/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
use Psr\Http\Message\ResponseInterface;
use Zend_Db_Exception;
use Zend_Db_Expr as Expr;
use Zend_Db_Select;
use Zend_Db_Statement_Exception;
use Zend_Db_Statement_Pdo;

Expand Down Expand Up @@ -315,6 +314,12 @@ class Product extends JobImport
* @var CollectionFactory $categoryCollectionFactory
*/
protected $categoryCollectionFactory;
/**
* The default name value when empty
*
* @var ?array $defaultNameValue
*/
protected $defaultNameValue = null;

/**
* Product constructor.
Expand Down Expand Up @@ -3677,7 +3682,7 @@ public function setUrlRewrite(): void
$productRows = $connection->fetchAll($productsSelect);

// Retrieve rewrite url at one time only for the current batch of products
$productsSelect->reset(Zend_Db_Select::COLUMNS)->columns('_entity_id');
$productsSelect->reset(Select::COLUMNS)->columns('_entity_id');
$urlRewriteQuery = $connection
->select()
->from($urlRewriteTable)
Expand Down Expand Up @@ -5090,7 +5095,21 @@ protected function handleNoName(array $product): array
if (array_key_exists(ProductInterface::NAME, $product['values'])) {
return $product;
}
$product['values'][ProductInterface::NAME][0]['data'] = '';

if ($this->defaultNameValue === null) {
try {
$attribute = $this->akeneoClient->getAttributeApi()->get(ProductInterface::NAME);
$this->defaultNameValue = [
'locale' => ($attribute['localizable'] ?? false) ? $this->storeHelper->getAdminLang() : null,
'scope' => ($attribute['scopable'] ?? false) ? $this->configHelper->getAdminDefaultChannel() : null,
'data' => '',
];
} catch (Exception) {
$this->defaultNameValue = ['locale' => null, 'scope' => null, 'data' => ''];
}
}

$product['values'][ProductInterface::NAME][0] = $this->defaultNameValue;

return $product;
}
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.0.7",
"version": "104.3.1",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down

0 comments on commit c751341

Please sign in to comment.