Skip to content

Commit c8c9c80

Browse files
Merge branch '2.4-develop' into AC-15107-Catalog
2 parents 3dfb06c + a8cf637 commit c8c9c80

File tree

22 files changed

+3181
-318
lines changed

22 files changed

+3181
-318
lines changed

app/code/Magento/Catalog/Model/ProductLink/Repository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function save(\Magento\Catalog\Api\Data\ProductLinkInterface $entity)
139139
. 'Please ensure the parent product SKU is provided and try again.'
140140
));
141141
}
142-
if (!$entity->getLinkedProductSku()) {
142+
if ($entity->getLinkedProductSku() === null || $entity->getLinkedProductSku() === '') {
143143
throw new CouldNotSaveException(__('The linked product SKU is invalid. Verify the data and try again.'));
144144
}
145145
$linkedProduct = $this->productRepository->get($entity->getLinkedProductSku());

app/code/Magento/Catalog/Test/Unit/Model/ProductLink/RepositoryTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,16 @@ public function testDeleteWithNoSuchEntityException()
298298

299299
$this->model->delete($entityMock);
300300
}
301+
302+
public function testSaveWithNullLinkedProductSku()
303+
{
304+
$this->expectException('Magento\Framework\Exception\CouldNotSaveException');
305+
$this->expectExceptionMessage('The linked product SKU is invalid. Verify the data and try again.');
306+
307+
$entityMock = $this->createMock(\Magento\Catalog\Model\ProductLink\Link::class);
308+
$entityMock->expects($this->any())->method('getSku')->willReturn('sku1');
309+
$entityMock->expects($this->any())->method('getLinkedProductSku')->willReturn(null);
310+
311+
$this->model->save($entityMock);
312+
}
301313
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Product/ProductCustomAttributes.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ function (AttributeInterface $customAttribute) {
108108
}
109109
$attributeValue = $productData[$attributeCode] ?? "";
110110
if (is_array($attributeValue)) {
111-
$attributeValue = implode(',', $attributeValue);
111+
$attributeValue = (count($attributeValue) != count($attributeValue, COUNT_RECURSIVE))
112+
? json_encode($attributeValue)
113+
: implode(',', $attributeValue);
112114
}
113115
$customAttributes[] = [
114116
'attribute_code' => $attributeCode,

0 commit comments

Comments
 (0)