Skip to content

Commit 9ffd2f6

Browse files
committed
31870: updated the if condition
1 parent 59b2840 commit 9ffd2f6

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

app/code/Magento/ConfigurableProduct/Model/Plugin/ProductRepositorySave.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ public function beforeSave(
6060
ProductInterface $product,
6161
$saveOptions = false
6262
): void {
63-
if ($product->getTypeId() === Configurable::TYPE_CODE
64-
&& null !== ($extensionAttributes = $product->getExtensionAttributes())
65-
) {
63+
$extensionAttributes = $product->getExtensionAttributes();
64+
if ($extensionAttributes !== null && $product->getTypeId() === Configurable::TYPE_CODE) {
6665
$configurableLinks = (array) $extensionAttributes->getConfigurableProductLinks();
6766
$configurableOptions = (array) $extensionAttributes->getConfigurableProductOptions();
6867

app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/ProductRepositorySaveTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ protected function setUp(): void
113113
*/
114114
public function testBeforeSaveWhenProductIsSimple(): void
115115
{
116-
$this->product->expects(static::once())
116+
$this->product->expects(static::atMost(1))
117117
->method('getTypeId')
118118
->willReturn('simple');
119-
$this->product->expects(static::never())
119+
$this->product->expects(static::once())
120120
->method('getExtensionAttributes');
121121

122122
$this->assertNull($this->plugin->beforeSave($this->productRepository, $this->product));

0 commit comments

Comments
 (0)