diff --git a/.gitignore b/.gitignore index 436c7ddd..5a9a7a9e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.vscode .idea/ -.DS_STORE +.DS_STORE \ No newline at end of file diff --git a/Model/Dibs/Items.php b/Model/Dibs/Items.php index ee5b5cda..69652439 100644 --- a/Model/Dibs/Items.php +++ b/Model/Dibs/Items.php @@ -262,7 +262,16 @@ public function addItems($items) $sku = $item->getSku(); //make sku unique (sku could not be unique when we have product with options) if (isset($this->_cart[$sku])) { - $sku = $sku . '-' . $item->getId(); + $itemRefId = $item->getId(); + /** + * use related order_item_id or quote_item_id when item id is not set + * error is observed when creating an invoice and there is more than two items with the same sku but with different configurations + * items after the second similar sku will replace the second item instead of appending as a separate item + */ + $itemRefId = $itemRefId ? $itemRefId : $item->getData('order_item_id'); + $itemRefId = $itemRefId ? $itemRefId : $item->getData('quote_item_id'); + $sku = $sku.'-'.$itemRefId; + } $itemName = $item->getName();