Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 175953c

Browse files
committed
feat(ImportOrder): support store for order import
Closes #499
1 parent 873170f commit 175953c

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/Core/Model/Order/ImportOrder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Commercetools\Core\Model\Cart\ShippingInfo;
1616
use Commercetools\Core\Model\Common\DateTimeDecorator;
1717
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft;
18+
use Commercetools\Core\Model\Store\StoreReference;
1819
use DateTime;
1920

2021
/**
@@ -65,6 +66,8 @@
6566
* @method ImportOrder setTaxCalculationMode(string $taxCalculationMode = null)
6667
* @method AddressCollection getItemShippingAddresses()
6768
* @method ImportOrder setItemShippingAddresses(AddressCollection $itemShippingAddresses = null)
69+
* @method StoreReference getStore()
70+
* @method ImportOrder setStore(StoreReference $store = null)
6871
*/
6972
class ImportOrder extends JsonObject
7073
{
@@ -96,6 +99,7 @@ public function fieldDefinitions()
9699
'origin' => [static::TYPE => 'string'],
97100
'taxCalculationMode' => [static::TYPE => 'string'],
98101
'itemShippingAddresses' => [static::TYPE => AddressCollection::class],
102+
'store' => [static::TYPE => StoreReference::class]
99103
];
100104
}
101105
}

tests/fixtures/models.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ importOrder:
3232
- origin
3333
- taxCalculationMode
3434
- itemShippingAddresses
35+
- store

tests/integration/Order/OrderImportRequestTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Commercetools\Core\Model\Order\ProductVariantImportDraft;
2323
use Commercetools\Core\Model\Order\ShippingInfoImportDraft;
2424
use Commercetools\Core\Model\ShippingMethod\ShippingRate;
25+
use Commercetools\Core\Model\Store\StoreReference;
2526
use Commercetools\Core\Request\Inventory\InventoryByIdGetRequest;
2627
use Commercetools\Core\Request\Inventory\InventoryCreateRequest;
2728
use Commercetools\Core\Request\Inventory\InventoryDeleteRequest;
@@ -73,6 +74,7 @@ public function getOriginTypes()
7374
'invalidOrigin' => ['invalidOrigin', false],
7475
];
7576
}
77+
7678
/**
7779
* @return ImportOrder
7880
*/
@@ -131,6 +133,19 @@ public function testImportOrder()
131133
$this->assertInstanceOf(Order::class, $order);
132134
}
133135

136+
public function testImportOrderStore()
137+
{
138+
$importOrder = $this->getOrderImportDraft();
139+
$store = $this->getStore();
140+
$importOrder->setStore(StoreReference::ofKey($store->getKey()));
141+
$order = $this->importOrder($importOrder);
142+
143+
$this->assertNotNull($order->getId());
144+
$this->assertNotNull($order->getVersion());
145+
$this->assertInstanceOf(Order::class, $order);
146+
$this->assertSame($store->getKey(), $order->getStore()->getKey());
147+
}
148+
134149
/**
135150
* @dataProvider getOriginTypes()
136151
* @param $origin

0 commit comments

Comments
 (0)