Skip to content

Commit 952c01e

Browse files
committed
MAGETWO-59074: Creditmemo return to stock only one unit of configurable product
1 parent f83ac29 commit 952c01e

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

app/code/Magento/Sales/Model/Order/CreditmemoFactory.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ class CreditmemoFactory
2222
*/
2323
protected $taxConfig;
2424

25+
/**
26+
* @var \Magento\Framework\Unserialize\Unserialize
27+
*/
28+
protected $unserialize;
29+
2530
/**
2631
* Factory constructor
2732
*
@@ -261,13 +266,27 @@ private function calculateProductOptions(\Magento\Sales\Api\Data\OrderItemInterf
261266
$qty = 1;
262267
$productOptions = $orderItem->getProductOptions();
263268
if (isset($productOptions['bundle_selection_attributes'])) {
264-
$bundleSelectionAttributes = unserialize(
265-
$productOptions['bundle_selection_attributes']
266-
);
269+
$bundleSelectionAttributes = $this->getUnserialize()
270+
->unserialize($productOptions['bundle_selection_attributes']);
267271
if ($bundleSelectionAttributes) {
268272
$qty = $bundleSelectionAttributes['qty'] * $qtys[$orderItem->getParentItemId()];
269273
}
270274
}
271275
return $qty;
272276
}
277+
278+
/**
279+
* Get Unserialize
280+
*
281+
* @return \Magento\Framework\Unserialize\Unserialize
282+
* @deprecated
283+
*/
284+
private function getUnserialize()
285+
{
286+
if (!$this->unserialize) {
287+
$this->unserialize = \Magento\Framework\App\ObjectManager::getInstance()
288+
->get(\Magento\Framework\Unserialize\Unserialize::class);
289+
}
290+
return $this->unserialize;
291+
}
273292
}

0 commit comments

Comments
 (0)