Skip to content

Commit 822a84d

Browse files
author
Viktor Kopin
committed
magento#1846 fix foreign key save error
1 parent f4f8e94 commit 822a84d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

AdobeStockAsset/Model/Asset.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ public function getId(): ?int
5656
/**
5757
* @inheritdoc
5858
*/
59-
public function getCategoryId(): int
59+
public function getCategoryId(): ?int
6060
{
61-
return (int) $this->getData(self::CATEGORY_ID);
61+
$categoryId = $this->getData(self::CATEGORY_ID);
62+
63+
return $categoryId !== null ? (int) $categoryId : null;
6264
}
6365

6466
/**

AdobeStockAsset/Model/SaveAsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function execute(AssetInterface $asset): void
7979
$data = $this->objectProcessor->buildOutputDataArray($asset, AssetInterface::class);
8080

8181
$category = $asset->getCategory();
82-
if ($category !== null) {
82+
if ($category->getId() !== null) {
8383
$category = $this->categoryRepository->save($category);
8484
}
8585
$data[self::CATEGORY_ID] = $category->getId();

0 commit comments

Comments
 (0)