Skip to content

Commit 10bd23b

Browse files
committed
Refs #24759: Order Create API Model - use product to find product in quote and request instead of SKU; increased package version
1 parent 3afe918 commit 10bd23b

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "budsies/magento1-vsbridge",
33
"description": "Vue Storefront bridge - Extension for Magento 1.x",
44
"type": "magento-module",
5-
"version": "1.0.2",
5+
"version": "1.0.3",
66
"authors": [
77
{
88
"name": "d.kochnov",

magento1-module/app/code/local/Divante/VueStorefrontBridge/Model/Api/Order/Create.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ private function checkAndAddProducts($requestPayload)
141141
$currentQuoteItems = $this->quote->getAllVisibleItems();
142142

143143
foreach ($clientItems as $product) {
144-
$sku = $product->sku;
145-
$serverItem = $this->findProductInQuote($sku, $currentQuoteItems);
144+
$serverItem = $this->findProductInQuote($product->id, $currentQuoteItems);
146145

147146
if ($serverItem) {
148147
if ($product->qty !== $serverItem->getQty()) {
@@ -168,7 +167,8 @@ private function checkAndAddProducts($requestPayload)
168167
}
169168

170169
foreach ($currentQuoteItems as $item) {
171-
$clientItem = $this->findProductInRequest($item->getData('sku'), $clientItems);
170+
$itemProductId = (int)$item->getData('product_id');
171+
$clientItem = $this->findProductInRequest($itemProductId, $clientItems);
172172

173173
if (null === $clientItem) {
174174
$this->quote->deleteItem($item);
@@ -187,26 +187,27 @@ private function addProductToQuote(stdClass $cartItem)
187187
}
188188

189189
/**
190-
* @param $sku
190+
* @param $productId
191191
* @param $items
192192
*
193193
* @return Mage_Sales_Model_Quote_Item|null
194194
*/
195-
private function findProductInQuote($sku, $items)
195+
private function findProductInQuote($productId, $items)
196196
{
197197
foreach ($items as $item) {
198-
if ($item->getData('sku') === $sku) {
198+
$itemProductId = (int)$item->getData('product_id');
199+
if ($itemProductId === $productId) {
199200
return $item;
200201
}
201202
}
202203

203204
return null;
204205
}
205206

206-
private function findProductInRequest($cartItemSku, $products)
207+
private function findProductInRequest($cartItemProductId, $products)
207208
{
208209
foreach ($products as $product) {
209-
if ($product->sku === $cartItemSku) {
210+
if ($product->id === $cartItemProductId) {
210211
return $product;
211212
}
212213
}

0 commit comments

Comments
 (0)