Skip to content

Commit b6aae28

Browse files
committed
ACP2E-924: MSI - Inventory Compensation command is not working properly for partial shipment of the Configurable products
1 parent 78d98c3 commit b6aae28

File tree

3 files changed

+33
-34
lines changed

3 files changed

+33
-34
lines changed

app/code/Magento/Bundle/Test/Fixture/AddProductToCart.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ public function __construct(
4545
/**
4646
* {@inheritdoc}
4747
* @param array $data Parameters
48-
* <pre>
49-
* $data = [
50-
* 'cart_id' => (int) Cart ID. Required.
51-
* 'product_id' => (int) Product ID. Required.
52-
* 'selections' => (array) array of options selections. Required.
53-
* 'qty' => (int) Quantity. Optional. Default: 1.
54-
* ]
55-
* </pre>
5648
* $data['selections'] can be supplied in following formats:
5749
* - [["$product1.id$"], ["$product2.id$"]]
5850
* - [[{"product_id":"$product1.id$","qty":1}], [{"product_id":"$product2.id$","qty":1}]]
5951
* - To skip an option, pass empty array [["$product1.id$"], [], ["$product2.id$"]]
52+
* <pre>
53+
* $data = [
54+
* 'cart_id' => (int) Cart ID. Required.
55+
* 'product_id' => (int) Product ID. Required.
56+
* 'selections' => (array) array of options selections. Required.
57+
* 'qty' => (int) Quantity. Optional. Default: 1.
58+
* ]
59+
* </pre>
6060
*/
6161
public function apply(array $data = []): ?DataObject
6262
{
@@ -71,25 +71,25 @@ public function apply(array $data = []): ?DataObject
7171
$options->appendSelections($selections, true);
7272
$optionsList = array_values($options->getItems());
7373
foreach ($data['selections'] as $index => $selections) {
74-
if (!empty($selections)) {
75-
$option = $optionsList[$index];
76-
foreach ($selections as $item) {
77-
if (is_array($item)) {
78-
$productId = (int) $item['product_id'];
79-
$qty = $item['qty'] ?? 1;
80-
} else {
81-
$productId = (int) $item;
82-
$qty = 1;
83-
}
84-
foreach ($option->getSelections() as $selection) {
85-
if (((int) $selection->getProductId()) === $productId) {
86-
$buyRequest['bundle_option'][$option->getId()][] = $selection->getSelectionId();
87-
$buyRequest['bundle_option_qty'][$option->getId()][$selection->getSelectionId()] = $qty;
88-
break;
89-
}
90-
}
91-
}
92-
}
74+
if (!empty($selections)) {
75+
$option = $optionsList[$index];
76+
foreach ($selections as $item) {
77+
if (is_array($item)) {
78+
$productId = (int)$item['product_id'];
79+
$qty = $item['qty'] ?? 1;
80+
} else {
81+
$productId = (int)$item;
82+
$qty = 1;
83+
}
84+
foreach ($option->getSelections() as $selection) {
85+
if (((int)$selection->getProductId()) === $productId) {
86+
$buyRequest['bundle_option'][$option->getId()][] = $selection->getSelectionId();
87+
$buyRequest['bundle_option_qty'][$option->getId()][$selection->getSelectionId()] = $qty;
88+
break;
89+
}
90+
}
91+
}
92+
}
9393
}
9494
return parent::apply(
9595
[

app/code/Magento/ConfigurableProduct/Test/Fixture/AddProductToCart.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct(
4949
* $data = [
5050
* 'cart_id' => (int) Cart ID. Required.
5151
* 'product_id' => (int) Product ID. Required.
52-
* 'child_product_id' => (int) Product ID. Required.
52+
* 'child_product_id' => (int) Child Product ID. Required.
5353
* 'qty' => (int) Quantity. Optional. Default: 1.
5454
* ]
5555
* </pre>
@@ -62,8 +62,8 @@ public function apply(array $data = []): ?DataObject
6262
'super_attribute' => [],
6363
'qty' => $data['qty'] ?? 1,
6464
];
65-
foreach ($this->productType->getUsedProductAttributes($configurableProduct) as $attribute) {
66-
$buyRequest['super_attribute'][$attribute->getId()] = $childProduct->getData($attribute->getAttributeCode());
65+
foreach ($this->productType->getUsedProductAttributes($configurableProduct) as $attr) {
66+
$buyRequest['super_attribute'][$attr->getId()] = $childProduct->getData($attr->getAttributeCode());
6767
}
6868
return parent::apply(
6969
[

app/code/Magento/GroupedProduct/Test/Fixture/AddProductToCart.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ public function __construct(
4242
$this->productType = $productType;
4343
}
4444

45-
4645
/**
4746
* {@inheritdoc}
4847
* @param array $data Parameters
48+
* $data['child_products'] can be supplied in following formats:
49+
* - ["$product1.id$", "$product2.id$"]
50+
* - [{"product_id":"$product1.id$","qty":1}, {"product_id":"$product2.id$","qty":1}]
4951
* <pre>
5052
* $data = [
5153
* 'cart_id' => (int) Cart ID. Required.
@@ -54,9 +56,6 @@ public function __construct(
5456
* 'qty' => (int) Quantity. Optional. Default: 1.
5557
* ]
5658
* </pre>
57-
* $data['selections'] can be supplied in following formats:
58-
* - ["$product1.id$", "$product2.id$"]
59-
* - [{"product_id":"$product1.id$","qty":1}, {"product_id":"$product2.id$","qty":1}]
6059
*/
6160
public function apply(array $data = []): ?DataObject
6261
{

0 commit comments

Comments
 (0)