From f82908bdc10b25141e6ed45c1a0da70a6e052214 Mon Sep 17 00:00:00 2001 From: "al.kravchuk" Date: Thu, 14 Mar 2019 11:02:46 +0200 Subject: [PATCH 1/8] MSI-2030-Add an ability to Mark Orders placed with Store Pickup. Declare db schema. --- .../InventoryInStorePickup/etc/db_schema.xml | 19 +++++++++++++++++++ .../etc/db_schema_whitelist.json | 13 +++++++++++++ .../InventoryInStorePickup/etc/module.xml | 7 ++++++- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/InventoryInStorePickup/etc/db_schema.xml create mode 100644 app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json diff --git a/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml b/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml new file mode 100644 index 000000000000..0c78adc5f012 --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + +
+
diff --git a/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json b/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json new file mode 100644 index 000000000000..a9279cae6e90 --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json @@ -0,0 +1,13 @@ +{ + "inventory_pickup_point_order": { + "column": { + "order_id": true, + "source_code": true + }, + "constraint": { + "PRIMARY": true, + "INV_ISP_ORDER_ORDER_ID_SALES_ORDER_ENTITY_ID": true, + "INV_ISP_ORDER_SOURCE_CODE_INV_SOURCE_SOURCE_CODE": true + } + } +} diff --git a/app/code/Magento/InventoryInStorePickup/etc/module.xml b/app/code/Magento/InventoryInStorePickup/etc/module.xml index 850ca9e9c6a7..cfd1f9e15713 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/module.xml +++ b/app/code/Magento/InventoryInStorePickup/etc/module.xml @@ -6,5 +6,10 @@ */ --> - + + + + + + From 95e787800186f7fcfac144e9f2d3753f8fab4a68 Mon Sep 17 00:00:00 2001 From: "al.kravchuk" Date: Thu, 14 Mar 2019 11:03:09 +0200 Subject: [PATCH 2/8] MSI-2030-Add an ability to Mark Orders placed with Store Pickup. Add new extension attribute. --- .../GetPickupPointByOrderId.php | 60 +++++++++++++++ .../OrderPickupPoint/SaveOrderPickupPoint.php | 57 ++++++++++++++ .../Order/GetPickupPointForOrderPlugin.php | 76 +++++++++++++++++++ .../Order/SavePickupPointForOrderPlugin.php | 52 +++++++++++++ .../InventoryInStorePickup/etc/db_schema.xml | 1 - .../etc/db_schema_whitelist.json | 3 +- .../Magento/InventoryInStorePickup/etc/di.xml | 13 ++++ .../etc/extension_attributes.xml | 12 +++ 8 files changed, 271 insertions(+), 3 deletions(-) create mode 100644 app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php create mode 100644 app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php create mode 100644 app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupPointForOrderPlugin.php create mode 100644 app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupPointForOrderPlugin.php create mode 100644 app/code/Magento/InventoryInStorePickup/etc/di.xml create mode 100644 app/code/Magento/InventoryInStorePickup/etc/extension_attributes.xml diff --git a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php new file mode 100644 index 000000000000..470cfbdfe7d3 --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php @@ -0,0 +1,60 @@ +connection = $connection; + } + + /** + * Fetch pickup point identifier by order identifier. + * + * @param int $orderId + * + * @return string|null + */ + public function execute(int $orderId):?string + { + $connection = $this->connection->getConnection(); + $table = $this->connection->getTableName('inventory_pickup_point_order'); + + $select = $connection->select() + ->from($table, [ + self::PICKUP_POINT_ID => self::PICKUP_POINT_ID + ]) + ->where(self::ORDER_ID . '= ?', $orderId) + ->limit(1); + + $id = $connection->fetchOne($select); + + return $id ?: null; + } +} diff --git a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php new file mode 100644 index 000000000000..51c4066f36a3 --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php @@ -0,0 +1,57 @@ +connection = $connection; + } + + /** + * Fetch pickup point identifier by order identifier. + * + * @param int $orderId + * @param string $pickupPointId + * + * @return void + */ + public function execute(int $orderId, string $pickupPointId):void + { + $connection = $this->connection->getConnection(); + $table = $this->connection->getTableName('inventory_pickup_point_order'); + + $data = [ + self::ORDER_ID => $orderId, + self::PICKUP_POINT_ID => $pickupPointId + ]; + + $connection->insertOnDuplicate($table, $data); + } +} diff --git a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupPointForOrderPlugin.php b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupPointForOrderPlugin.php new file mode 100644 index 000000000000..a95178536a06 --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupPointForOrderPlugin.php @@ -0,0 +1,76 @@ +orderExtensionFactory = $orderExtensionFactory; + $this->getPickupPointByOrderId = $getPickupPointByOrderId; + } + + /** + * @param OrderRepositoryInterface $orderRepository + * @param OrderInterface $order + * + * @return OrderInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterGet( + OrderRepositoryInterface $orderRepository, + OrderInterface $order + ):OrderInterface { + $extension = $order->getExtensionAttributes(); + + if (empty($extension)) { + $extension = $this->orderExtensionFactory->create(); + } + + if ($extension->getPickupPointId()) { + return $order; + } + + $pickupPointId = $this->getPickupPointByOrderId->execute((int)$order->getEntityId()); + + if ($pickupPointId) { + $extension->setPickupPointId($pickupPointId); + } + + $order->setExtensionAttributes($extension); + + return $order; + } +} diff --git a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupPointForOrderPlugin.php b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupPointForOrderPlugin.php new file mode 100644 index 000000000000..65bb91f0d888 --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupPointForOrderPlugin.php @@ -0,0 +1,52 @@ +saveOrderPickupPoint = $saveOrderPickupPoint; + } + + /** + * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository + * @param \Magento\Sales\Api\Data\OrderInterface $result + * @param \Magento\Sales\Api\Data\OrderInterface $entity + * + * @return \Magento\Sales\Api\Data\OrderInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterSave( + OrderRepositoryInterface $orderRepository, + OrderInterface $result, + OrderInterface $entity + ) { + $extension = $result->getExtensionAttributes(); + + if (!empty($extension) && $extension->getPickupPointId()) { + $this->saveOrderPickupPoint->execute((int)$result->getEntityId(), $extension->getPickupPointId()); + } + + return $result; + } +} diff --git a/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml b/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml index 0c78adc5f012..15815b6e8250 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml +++ b/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml @@ -11,7 +11,6 @@ - diff --git a/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json b/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json index a9279cae6e90..35bea27ebcb6 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json +++ b/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json @@ -6,8 +6,7 @@ }, "constraint": { "PRIMARY": true, - "INV_ISP_ORDER_ORDER_ID_SALES_ORDER_ENTITY_ID": true, - "INV_ISP_ORDER_SOURCE_CODE_INV_SOURCE_SOURCE_CODE": true + "INV_ISP_ORDER_ORDER_ID_SALES_ORDER_ENTITY_ID": true } } } diff --git a/app/code/Magento/InventoryInStorePickup/etc/di.xml b/app/code/Magento/InventoryInStorePickup/etc/di.xml new file mode 100644 index 000000000000..67b601583f47 --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/etc/di.xml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/app/code/Magento/InventoryInStorePickup/etc/extension_attributes.xml b/app/code/Magento/InventoryInStorePickup/etc/extension_attributes.xml new file mode 100644 index 000000000000..7fbc043f7d8b --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/etc/extension_attributes.xml @@ -0,0 +1,12 @@ + + + + + + + From ec60951783353b9d35887f39071c102d2cbfc6be Mon Sep 17 00:00:00 2001 From: "al.kravchuk" Date: Thu, 14 Mar 2019 16:26:20 +0200 Subject: [PATCH 3/8] MSI-2030-Add an ability to Mark Orders placed with Store Pickup. Decrease schema dependency on inventory_source. --- .../ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php | 2 +- .../ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php | 2 +- app/code/Magento/InventoryInStorePickup/etc/db_schema.xml | 2 +- .../Magento/InventoryInStorePickup/etc/db_schema_whitelist.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php index 470cfbdfe7d3..301a750ac3f3 100644 --- a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php +++ b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php @@ -16,7 +16,7 @@ class GetPickupPointByOrderId { const ORDER_ID = 'order_id'; - const PICKUP_POINT_ID = 'source_code'; + const PICKUP_POINT_ID = 'pickup_point_id'; /** * @var \Magento\Framework\App\ResourceConnection diff --git a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php index 51c4066f36a3..057d82856fa9 100644 --- a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php +++ b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php @@ -16,7 +16,7 @@ class SaveOrderPickupPoint { const ORDER_ID = 'order_id'; - const PICKUP_POINT_ID = 'source_code'; + const PICKUP_POINT_ID = 'pickup_point_id'; /** * @var \Magento\Framework\App\ResourceConnection diff --git a/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml b/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml index 15815b6e8250..2a665915e9e4 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml +++ b/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml @@ -9,7 +9,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> - + diff --git a/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json b/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json index 35bea27ebcb6..ce38ddd7b58c 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json +++ b/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json @@ -2,7 +2,7 @@ "inventory_pickup_point_order": { "column": { "order_id": true, - "source_code": true + "pickup_point_id": true }, "constraint": { "PRIMARY": true, From 4b5296a3d49485c38099a4562df9a4b1709f7b96 Mon Sep 17 00:00:00 2001 From: "al.kravchuk" Date: Fri, 15 Mar 2019 09:59:21 +0200 Subject: [PATCH 4/8] MSI-2030-Add an ability to Mark Orders placed with Store Pickup. Fix tests and apply code review corrections. --- .../OrderPickupPoint/GetPickupPointByOrderId.php | 5 ++--- .../ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php | 5 ++--- .../Plugin/Sales/Order/GetPickupPointForOrderPlugin.php | 1 - .../Plugin/Sales/Order/SavePickupPointForOrderPlugin.php | 3 +++ app/code/Magento/InventoryInStorePickup/composer.json | 5 +++-- app/code/Magento/InventoryInStorePickup/etc/db_schema.xml | 2 +- .../InventoryInStorePickup/etc/db_schema_whitelist.json | 2 +- app/code/Magento/InventoryInStorePickup/etc/module.xml | 1 - 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php index 301a750ac3f3..d30cce1cbfdb 100644 --- a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php +++ b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php @@ -10,13 +10,12 @@ use Magento\Framework\App\ResourceConnection; /** - * Class GetPickupPointByOrderId. * Get Pickup Point identifier by order identifier. */ class GetPickupPointByOrderId { - const ORDER_ID = 'order_id'; - const PICKUP_POINT_ID = 'pickup_point_id'; + private const ORDER_ID = 'order_id'; + private const PICKUP_POINT_ID = 'pickup_point_id'; /** * @var \Magento\Framework\App\ResourceConnection diff --git a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php index 057d82856fa9..18f0dbf16c58 100644 --- a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php +++ b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php @@ -10,13 +10,12 @@ use Magento\Framework\App\ResourceConnection; /** - * Class SaveOrderPickupPoint. * Save Order Pickup Point */ class SaveOrderPickupPoint { - const ORDER_ID = 'order_id'; - const PICKUP_POINT_ID = 'pickup_point_id'; + private const ORDER_ID = 'order_id'; + private const PICKUP_POINT_ID = 'pickup_point_id'; /** * @var \Magento\Framework\App\ResourceConnection diff --git a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupPointForOrderPlugin.php b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupPointForOrderPlugin.php index a95178536a06..8fda57e8182a 100644 --- a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupPointForOrderPlugin.php +++ b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupPointForOrderPlugin.php @@ -13,7 +13,6 @@ use Magento\Sales\Api\OrderRepositoryInterface; /** - * Class GetPickupPointForOrderPlugin. * Set Pickup Point Identifier to Order Entity. */ class GetPickupPointForOrderPlugin diff --git a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupPointForOrderPlugin.php b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupPointForOrderPlugin.php index 65bb91f0d888..ebf04f38a518 100644 --- a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupPointForOrderPlugin.php +++ b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupPointForOrderPlugin.php @@ -11,6 +11,9 @@ use Magento\Sales\Api\OrderRepositoryInterface; use Magento\Sales\Api\Data\OrderInterface; +/** + * Save Pickup Point Identifier, related to the Order Entity. + */ class SavePickupPointForOrderPlugin { /** diff --git a/app/code/Magento/InventoryInStorePickup/composer.json b/app/code/Magento/InventoryInStorePickup/composer.json index f0bb6012fb9c..b0274a43d377 100644 --- a/app/code/Magento/InventoryInStorePickup/composer.json +++ b/app/code/Magento/InventoryInStorePickup/composer.json @@ -3,8 +3,9 @@ "description": "N/A", "require": { "php": "~7.1.3||~7.2.0", - "magento/framework": "*" - }, + "magento/framework": "*", + "magento/module-sales": "*" + },, "type": "magento2-module", "license": [ "OSL-3.0", diff --git a/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml b/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml index 2a665915e9e4..c043b4cfde9d 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml +++ b/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml @@ -10,7 +10,7 @@
- + diff --git a/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json b/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json index ce38ddd7b58c..27d39e412d18 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json +++ b/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json @@ -6,7 +6,7 @@ }, "constraint": { "PRIMARY": true, - "INV_ISP_ORDER_ORDER_ID_SALES_ORDER_ENTITY_ID": true + "INVENTORY_PICKUP_POINT_ORDER_ORDER_ID_SALES_ORDER_ENTITY_ID": true } } } diff --git a/app/code/Magento/InventoryInStorePickup/etc/module.xml b/app/code/Magento/InventoryInStorePickup/etc/module.xml index cfd1f9e15713..224ec751bd77 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/module.xml +++ b/app/code/Magento/InventoryInStorePickup/etc/module.xml @@ -9,7 +9,6 @@ - From 354806145468c201a3943e43c340fe897ba55e39 Mon Sep 17 00:00:00 2001 From: "al.kravchuk" Date: Sun, 17 Mar 2019 22:05:52 +0200 Subject: [PATCH 5/8] MSI-2030-Add an ability to Mark Orders placed with Store Pickup. Add integration test for order placement. MSI-2030-Add an ability to Mark Orders placed with Store Pickup. --- .../Test/Integration/PickupPointOrderTest.php | 85 +++++++++++++++++++ ...te_in_store_pickup_quote_on_eu_website.php | 59 +++++++++++++ ...re_pickup_quote_on_eu_website_rollback.php | 40 +++++++++ .../Test/_files/place_order.php | 37 ++++++++ .../Test/_files/place_order_rollback.php | 41 +++++++++ 5 files changed, 262 insertions(+) create mode 100644 app/code/Magento/InventoryInStorePickup/Test/Integration/PickupPointOrderTest.php create mode 100644 app/code/Magento/InventoryInStorePickup/Test/_files/create_in_store_pickup_quote_on_eu_website.php create mode 100644 app/code/Magento/InventoryInStorePickup/Test/_files/create_in_store_pickup_quote_on_eu_website_rollback.php create mode 100644 app/code/Magento/InventoryInStorePickup/Test/_files/place_order.php create mode 100644 app/code/Magento/InventoryInStorePickup/Test/_files/place_order_rollback.php diff --git a/app/code/Magento/InventoryInStorePickup/Test/Integration/PickupPointOrderTest.php b/app/code/Magento/InventoryInStorePickup/Test/Integration/PickupPointOrderTest.php new file mode 100644 index 000000000000..e598cdd6acda --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/Test/Integration/PickupPointOrderTest.php @@ -0,0 +1,85 @@ +objectManager = Bootstrap::getObjectManager(); + + $this->orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); + $this->searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class); + $this->orderExtensionFactory = $this->objectManager->get(OrderExtensionFactory::class); + } + + /** + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryInStorePickup/Test/_files/create_in_store_pickup_quote_on_eu_website.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryInStorePickup/Test/_files/place_order.php + * + * @magentoDbIsolation disabled + */ + public function testPickupPointSaveWithOrder() + { + $sourceId = 'eu-1'; + + $searchCriteria = $this->searchCriteriaBuilder + ->addFilter('increment_id', 'in_store_pickup_test_order') + ->create(); + /** @var OrderInterface $createdOrder */ + $createdOrder = current($this->orderRepository->getList($searchCriteria)->getItems()); + $orderId = $createdOrder->getEntityId(); + + $extension = $createdOrder->getExtensionAttributes(); + + if (empty($extension)) { + /** @var \Magento\Sales\Api\Data\OrderExtensionInterface $extension */ + $extension = $this->orderExtensionFactory->create(); + } + + $extension->setPickupPointId($sourceId); + $createdOrder->setExtensionAttributes($extension); + + $this->orderRepository->save($createdOrder); + + // Remove value to re-load from DB during 'get'. + $extension->setPickupPointId(null); + + $order = $this->orderRepository->get($orderId); + + $this->assertEquals($order->getExtensionAttributes()->getPickupPointId(), $sourceId); + } +} diff --git a/app/code/Magento/InventoryInStorePickup/Test/_files/create_in_store_pickup_quote_on_eu_website.php b/app/code/Magento/InventoryInStorePickup/Test/_files/create_in_store_pickup_quote_on_eu_website.php new file mode 100644 index 000000000000..fa289d7dbb02 --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/Test/_files/create_in_store_pickup_quote_on_eu_website.php @@ -0,0 +1,59 @@ +get(CartRepositoryInterface::class); +/** @var CartManagementInterface $cartManagement */ +$cartManagement = Bootstrap::getObjectManager()->get(CartManagementInterface::class); +/** @var AddressInterfaceFactory $addressFactory */ +$addressFactory = Bootstrap::getObjectManager()->get(AddressInterfaceFactory::class); +/** @var StoreRepositoryInterface $storeRepository */ +$storeRepository = Bootstrap::getObjectManager()->get(StoreRepositoryInterface::class); +/** @var StoreManagerInterface\ $storeManager */ +$storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); + +$cartId = $cartManagement->createEmptyCart(); +$cart = $cartRepository->get($cartId); +$cart->setCustomerEmail('admin@example.com'); +$cart->setCustomerIsGuest(true); +$store = $storeRepository->get('store_for_eu_website'); +$cart->setStoreId($store->getId()); +$storeManager->setCurrentStore($store->getCode()); + +/** @var AddressInterface $address */ +$address = $addressFactory->create( + [ + 'data' => [ + AddressInterface::KEY_COUNTRY_ID => 'US', + AddressInterface::KEY_REGION_ID => 15, + AddressInterface::KEY_LASTNAME => 'Doe', + AddressInterface::KEY_FIRSTNAME => 'John', + AddressInterface::KEY_STREET => 'example street', + AddressInterface::KEY_EMAIL => 'customer@example.com', + AddressInterface::KEY_CITY => 'Los Angeles', + AddressInterface::KEY_TELEPHONE => '937 99 92', + AddressInterface::KEY_POSTCODE => 12345 + ] + ] +); +$cart->setReservedOrderId('in_store_pickup_test_order'); +$cart->setBillingAddress($address); +$cart->setShippingAddress($address); +$cart->getPayment()->setMethod('checkmo'); +/** Will be replaced with 'In Store Pickup' delivery method */ +$cart->getShippingAddress()->setShippingMethod('flatrate_flatrate'); +$cart->getShippingAddress()->setCollectShippingRates(true); +$cart->getShippingAddress()->collectShippingRates(); +$cartRepository->save($cart); diff --git a/app/code/Magento/InventoryInStorePickup/Test/_files/create_in_store_pickup_quote_on_eu_website_rollback.php b/app/code/Magento/InventoryInStorePickup/Test/_files/create_in_store_pickup_quote_on_eu_website_rollback.php new file mode 100644 index 000000000000..0ac614eb443d --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/Test/_files/create_in_store_pickup_quote_on_eu_website_rollback.php @@ -0,0 +1,40 @@ +get(Registry::class); + +/** @var CartRepositoryInterface $cartRepository */ +$cartRepository = Bootstrap::getObjectManager()->get(CartRepositoryInterface::class); +/** @var SearchCriteriaBuilder $searchCriteriaBuilder */ +$searchCriteriaBuilder = Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class); + +$searchCriteria = $searchCriteriaBuilder + ->addFilter('reserved_order_id', 'in_store_pickup_test_order') + ->create(); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var CartInterface[] $order */ +$carts = $cartRepository->getList($searchCriteria)->getItems(); +foreach ($carts as $cart) { + $cartRepository->delete($cart); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); + +/* Refresh stores memory cache */ +Bootstrap::getObjectManager()->get(StoreManagerInterface::class)->reinitStores(); diff --git a/app/code/Magento/InventoryInStorePickup/Test/_files/place_order.php b/app/code/Magento/InventoryInStorePickup/Test/_files/place_order.php new file mode 100644 index 000000000000..8e5a39c7e3ea --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/Test/_files/place_order.php @@ -0,0 +1,37 @@ +get(SearchCriteriaBuilder::class); +/** @var CartRepositoryInterface $cartRepository */ +$cartRepository = Bootstrap::getObjectManager()->get(CartRepositoryInterface::class); +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); +/** @var CartManagementInterface $cartManagement */ +$cartManagement = Bootstrap::getObjectManager()->get(CartManagementInterface::class); + +$searchCriteria = $searchCriteriaBuilder + ->addFilter('reserved_order_id', 'in_store_pickup_test_order') + ->create(); +$cart = current($cartRepository->getList($searchCriteria)->getItems()); + +$product = $productRepository->get('SKU-1'); +$requestData = [ + 'product' => $product->getProductId(), + 'qty' => 3.5 +]; +$request = new \Magento\Framework\DataObject($requestData); +$cart->addProduct($product, $request); + +$cartRepository->save($cart); +$cartManagement->placeOrder($cart->getId()); diff --git a/app/code/Magento/InventoryInStorePickup/Test/_files/place_order_rollback.php b/app/code/Magento/InventoryInStorePickup/Test/_files/place_order_rollback.php new file mode 100644 index 000000000000..194465bb9eaa --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/Test/_files/place_order_rollback.php @@ -0,0 +1,41 @@ +get(Registry::class); + +/** @var OrderRepositoryInterface $orderRepository */ +$orderRepository = Bootstrap::getObjectManager()->get(OrderRepositoryInterface::class); +/** @var OrderManagementInterface $orderManagement */ +$orderManagement = Bootstrap::getObjectManager()->get(OrderManagementInterface::class); +/** @var SearchCriteriaBuilder $searchCriteriaBuilder */ +$searchCriteriaBuilder = Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class); + +$searchCriteria = $searchCriteriaBuilder + ->addFilter('increment_id', 'in_store_pickup_test_order') + ->create(); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var OrderInterface $order */ +$order = current($orderRepository->getList($searchCriteria)->getItems()); +if ($order) { + $orderManagement->cancel($order->getEntityId()); + $orderRepository->delete($order); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); From b600990fb6b47a8e85311b7e2b1de7c31641d0b4 Mon Sep 17 00:00:00 2001 From: "al.kravchuk" Date: Fri, 22 Mar 2019 13:44:14 +0200 Subject: [PATCH 6/8] MSI-2030-Add an ability to Mark Orders placed with Store Pickup. Pickup Point -> Pickup Location Pickup Point Id -> Pickup Location Code --- .../GetPickupLocationByOrderId.php} | 16 +++++------ .../SaveOrderPickupLocation.php} | 20 ++++++------- ...hp => GetPickupLocationForOrderPlugin.php} | 28 +++++++++---------- ...p => SavePickupLocationForOrderPlugin.php} | 22 +++++++-------- ...erTest.php => PickupLocationOrderTest.php} | 10 +++---- .../InventoryInStorePickup/etc/db_schema.xml | 6 ++-- .../etc/db_schema_whitelist.json | 6 ++-- .../Magento/InventoryInStorePickup/etc/di.xml | 4 +-- .../etc/extension_attributes.xml | 2 +- 9 files changed, 57 insertions(+), 57 deletions(-) rename app/code/Magento/InventoryInStorePickup/Model/ResourceModel/{OrderPickupPoint/GetPickupPointByOrderId.php => OrderPickupLocation/GetPickupLocationByOrderId.php} (74%) rename app/code/Magento/InventoryInStorePickup/Model/ResourceModel/{OrderPickupPoint/SaveOrderPickupPoint.php => OrderPickupLocation/SaveOrderPickupLocation.php} (67%) rename app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/{GetPickupPointForOrderPlugin.php => GetPickupLocationForOrderPlugin.php} (63%) rename app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/{SavePickupPointForOrderPlugin.php => SavePickupLocationForOrderPlugin.php} (59%) rename app/code/Magento/InventoryInStorePickup/Test/Integration/{PickupPointOrderTest.php => PickupLocationOrderTest.php} (93%) diff --git a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/GetPickupLocationByOrderId.php similarity index 74% rename from app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php rename to app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/GetPickupLocationByOrderId.php index d30cce1cbfdb..2d5101e81f5e 100644 --- a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/GetPickupPointByOrderId.php +++ b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/GetPickupLocationByOrderId.php @@ -5,17 +5,17 @@ */ declare(strict_types=1); -namespace Magento\InventoryInStorePickup\Model\ResourceModel\OrderPickupPoint; +namespace Magento\InventoryInStorePickup\Model\ResourceModel\OrderPickupLocation; use Magento\Framework\App\ResourceConnection; /** - * Get Pickup Point identifier by order identifier. + * Get Pickup Location identifier by order identifier. */ -class GetPickupPointByOrderId +class GetPickupLocationByOrderId { private const ORDER_ID = 'order_id'; - private const PICKUP_POINT_ID = 'pickup_point_id'; + private const PICKUP_LOCATION_CODE = 'pickup_location_code'; /** * @var \Magento\Framework\App\ResourceConnection @@ -23,7 +23,7 @@ class GetPickupPointByOrderId private $connection; /** - * GetPickupPointByOrderId constructor. + * GetPickupLocationByOrderId constructor. * * @param \Magento\Framework\App\ResourceConnection $connection */ @@ -34,7 +34,7 @@ public function __construct( } /** - * Fetch pickup point identifier by order identifier. + * Fetch pickup location identifier by order identifier. * * @param int $orderId * @@ -43,11 +43,11 @@ public function __construct( public function execute(int $orderId):?string { $connection = $this->connection->getConnection(); - $table = $this->connection->getTableName('inventory_pickup_point_order'); + $table = $this->connection->getTableName('inventory_pickup_location_order'); $select = $connection->select() ->from($table, [ - self::PICKUP_POINT_ID => self::PICKUP_POINT_ID + self::PICKUP_LOCATION_CODE => self::PICKUP_LOCATION_CODE ]) ->where(self::ORDER_ID . '= ?', $orderId) ->limit(1); diff --git a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/SaveOrderPickupLocation.php similarity index 67% rename from app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php rename to app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/SaveOrderPickupLocation.php index 18f0dbf16c58..96765931c7ed 100644 --- a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupPoint/SaveOrderPickupPoint.php +++ b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/SaveOrderPickupLocation.php @@ -5,17 +5,17 @@ */ declare(strict_types=1); -namespace Magento\InventoryInStorePickup\Model\ResourceModel\OrderPickupPoint; +namespace Magento\InventoryInStorePickup\Model\ResourceModel\OrderPickupLocation; use Magento\Framework\App\ResourceConnection; /** - * Save Order Pickup Point + * Save Order Pickup Location */ -class SaveOrderPickupPoint +class SaveOrderPickupLocation { private const ORDER_ID = 'order_id'; - private const PICKUP_POINT_ID = 'pickup_point_id'; + private const PICKUP_LOCATION_CODE = 'pickup_location_code'; /** * @var \Magento\Framework\App\ResourceConnection @@ -23,7 +23,7 @@ class SaveOrderPickupPoint private $connection; /** - * GetPickupPointByOrderId constructor. + * GetPickupLocationByOrderId constructor. * * @param \Magento\Framework\App\ResourceConnection $connection */ @@ -34,21 +34,21 @@ public function __construct( } /** - * Fetch pickup point identifier by order identifier. + * Fetch pickup location identifier by order identifier. * * @param int $orderId - * @param string $pickupPointId + * @param string $pickupLocationCode * * @return void */ - public function execute(int $orderId, string $pickupPointId):void + public function execute(int $orderId, string $pickupLocationCode):void { $connection = $this->connection->getConnection(); - $table = $this->connection->getTableName('inventory_pickup_point_order'); + $table = $this->connection->getTableName('inventory_pickup_location_order'); $data = [ self::ORDER_ID => $orderId, - self::PICKUP_POINT_ID => $pickupPointId + self::PICKUP_LOCATION_CODE => $pickupLocationCode ]; $connection->insertOnDuplicate($table, $data); diff --git a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupPointForOrderPlugin.php b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupLocationForOrderPlugin.php similarity index 63% rename from app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupPointForOrderPlugin.php rename to app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupLocationForOrderPlugin.php index 8fda57e8182a..1194ee4ede84 100644 --- a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupPointForOrderPlugin.php +++ b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupLocationForOrderPlugin.php @@ -7,15 +7,15 @@ namespace Magento\InventoryInStorePickup\Plugin\Sales\Order; -use Magento\InventoryInStorePickup\Model\ResourceModel\OrderPickupPoint\GetPickupPointByOrderId; +use Magento\InventoryInStorePickup\Model\ResourceModel\OrderPickupLocation\GetPickupLocationByOrderId; use Magento\Sales\Api\Data\OrderExtensionFactory; use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\OrderRepositoryInterface; /** - * Set Pickup Point Identifier to Order Entity. + * Set Pickup Location identifier to Order Entity. */ -class GetPickupPointForOrderPlugin +class GetPickupLocationForOrderPlugin { /** * @var OrderExtensionFactory @@ -23,22 +23,22 @@ class GetPickupPointForOrderPlugin private $orderExtensionFactory; /** - * @var GetPickupPointByOrderId + * @var GetPickupLocationByOrderId */ - private $getPickupPointByOrderId; + private $getPickupLocationByOrderId; /** - * GetPickupPointForOrderPlugin constructor. + * GetPickupLocationForOrderPlugin constructor. * - * @param OrderExtensionFactory $orderExtensionFactory - * @param GetPickupPointByOrderId $getPickupPointByOrderId + * @param OrderExtensionFactory $orderExtensionFactory + * @param GetPickupLocationByOrderId $getPickupLocationByOrderId */ public function __construct( OrderExtensionFactory $orderExtensionFactory, - GetPickupPointByOrderId $getPickupPointByOrderId + GetPickupLocationByOrderId $getPickupLocationByOrderId ) { $this->orderExtensionFactory = $orderExtensionFactory; - $this->getPickupPointByOrderId = $getPickupPointByOrderId; + $this->getPickupLocationByOrderId = $getPickupLocationByOrderId; } /** @@ -58,14 +58,14 @@ public function afterGet( $extension = $this->orderExtensionFactory->create(); } - if ($extension->getPickupPointId()) { + if ($extension->getPickupLocationCode()) { return $order; } - $pickupPointId = $this->getPickupPointByOrderId->execute((int)$order->getEntityId()); + $pickupLocationCode = $this->getPickupLocationByOrderId->execute((int)$order->getEntityId()); - if ($pickupPointId) { - $extension->setPickupPointId($pickupPointId); + if ($pickupLocationCode) { + $extension->setPickupLocationCode($pickupLocationCode); } $order->setExtensionAttributes($extension); diff --git a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupPointForOrderPlugin.php b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupLocationForOrderPlugin.php similarity index 59% rename from app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupPointForOrderPlugin.php rename to app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupLocationForOrderPlugin.php index ebf04f38a518..80fe5e8970eb 100644 --- a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupPointForOrderPlugin.php +++ b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupLocationForOrderPlugin.php @@ -7,28 +7,28 @@ namespace Magento\InventoryInStorePickup\Plugin\Sales\Order; -use Magento\InventoryInStorePickup\Model\ResourceModel\OrderPickupPoint\SaveOrderPickupPoint; +use Magento\InventoryInStorePickup\Model\ResourceModel\OrderPickupLocation\SaveOrderPickupLocation; use Magento\Sales\Api\OrderRepositoryInterface; use Magento\Sales\Api\Data\OrderInterface; /** - * Save Pickup Point Identifier, related to the Order Entity. + * Save Pickup Location identifier, related to the Order Entity. */ -class SavePickupPointForOrderPlugin +class SavePickupLocationForOrderPlugin { /** - * @var SaveOrderPickupPoint + * @var SaveOrderPickupLocation */ - private $saveOrderPickupPoint; + private $saveOrderPickupLocation; /** - * SavePickupPointForOrderPlugin constructor. + * SavePickupLocationForOrderPlugin constructor. * - * @param SaveOrderPickupPoint $saveOrderPickupPoint + * @param SaveOrderPickupLocation $saveOrderPickupLocation */ - public function __construct(SaveOrderPickupPoint $saveOrderPickupPoint) + public function __construct(SaveOrderPickupLocation $saveOrderPickupLocation) { - $this->saveOrderPickupPoint = $saveOrderPickupPoint; + $this->saveOrderPickupLocation = $saveOrderPickupLocation; } /** @@ -46,8 +46,8 @@ public function afterSave( ) { $extension = $result->getExtensionAttributes(); - if (!empty($extension) && $extension->getPickupPointId()) { - $this->saveOrderPickupPoint->execute((int)$result->getEntityId(), $extension->getPickupPointId()); + if (!empty($extension) && $extension->getPickupLocationCode()) { + $this->saveOrderPickupLocation->execute((int)$result->getEntityId(), $extension->getPickupLocationCode()); } return $result; diff --git a/app/code/Magento/InventoryInStorePickup/Test/Integration/PickupPointOrderTest.php b/app/code/Magento/InventoryInStorePickup/Test/Integration/PickupLocationOrderTest.php similarity index 93% rename from app/code/Magento/InventoryInStorePickup/Test/Integration/PickupPointOrderTest.php rename to app/code/Magento/InventoryInStorePickup/Test/Integration/PickupLocationOrderTest.php index e598cdd6acda..ef2321e737d9 100644 --- a/app/code/Magento/InventoryInStorePickup/Test/Integration/PickupPointOrderTest.php +++ b/app/code/Magento/InventoryInStorePickup/Test/Integration/PickupLocationOrderTest.php @@ -15,7 +15,7 @@ use Magento\TestFramework\Helper\Bootstrap; use PHPUnit\Framework\TestCase; -class PickupPointOrderTest extends TestCase +class PickupLocationOrderTest extends TestCase { /** @var ObjectManagerInterface */ private $objectManager; @@ -52,7 +52,7 @@ protected function setUp() * * @magentoDbIsolation disabled */ - public function testPickupPointSaveWithOrder() + public function testPickupLocationSaveWithOrder() { $sourceId = 'eu-1'; @@ -70,16 +70,16 @@ public function testPickupPointSaveWithOrder() $extension = $this->orderExtensionFactory->create(); } - $extension->setPickupPointId($sourceId); + $extension->setPickupLocationCode($sourceId); $createdOrder->setExtensionAttributes($extension); $this->orderRepository->save($createdOrder); // Remove value to re-load from DB during 'get'. - $extension->setPickupPointId(null); + $extension->setPickupLocationCode(null); $order = $this->orderRepository->get($orderId); - $this->assertEquals($order->getExtensionAttributes()->getPickupPointId(), $sourceId); + $this->assertEquals($order->getExtensionAttributes()->getPickupLocationCode(), $sourceId); } } diff --git a/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml b/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml index c043b4cfde9d..ce0351a1aba0 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml +++ b/app/code/Magento/InventoryInStorePickup/etc/db_schema.xml @@ -7,10 +7,10 @@ --> -
+
- - + + diff --git a/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json b/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json index 27d39e412d18..6577e0903af9 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json +++ b/app/code/Magento/InventoryInStorePickup/etc/db_schema_whitelist.json @@ -1,12 +1,12 @@ { - "inventory_pickup_point_order": { + "inventory_pickup_location_order": { "column": { "order_id": true, - "pickup_point_id": true + "pickup_location_code": true }, "constraint": { "PRIMARY": true, - "INVENTORY_PICKUP_POINT_ORDER_ORDER_ID_SALES_ORDER_ENTITY_ID": true + "INVENTORY_PICKUP_LOCATION_ORDER_ORDER_ID_SALES_ORDER_ENTITY_ID": true } } } diff --git a/app/code/Magento/InventoryInStorePickup/etc/di.xml b/app/code/Magento/InventoryInStorePickup/etc/di.xml index e0c9e15a02d3..a7d9095347de 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/di.xml +++ b/app/code/Magento/InventoryInStorePickup/etc/di.xml @@ -7,8 +7,8 @@ --> - - + + diff --git a/app/code/Magento/InventoryInStorePickup/etc/extension_attributes.xml b/app/code/Magento/InventoryInStorePickup/etc/extension_attributes.xml index 7fbc043f7d8b..5a1cb9f58801 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/extension_attributes.xml +++ b/app/code/Magento/InventoryInStorePickup/etc/extension_attributes.xml @@ -7,6 +7,6 @@ --> - + From c06e37c1c945104dec51befea921ba2b8d68ccf7 Mon Sep 17 00:00:00 2001 From: "al.kravchuk" Date: Fri, 22 Mar 2019 14:07:58 +0200 Subject: [PATCH 7/8] MSI-2030-Add an ability to Mark Orders placed with Store Pickup. Add join directive for extension attribute. --- .../InventoryInStorePickup/etc/extension_attributes.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/InventoryInStorePickup/etc/extension_attributes.xml b/app/code/Magento/InventoryInStorePickup/etc/extension_attributes.xml index 5a1cb9f58801..9658b9c75e5e 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/extension_attributes.xml +++ b/app/code/Magento/InventoryInStorePickup/etc/extension_attributes.xml @@ -7,6 +7,10 @@ --> - + + + pickup_location_code + + From 97556b5ca60668b8c4302efe85d7dae8ce8d5ae7 Mon Sep 17 00:00:00 2001 From: Ievgen Shakhsuvarov Date: Fri, 22 Mar 2019 16:39:56 -0500 Subject: [PATCH 8/8] magento-engcom/msi#2082: Minor coding style fixes --- .../GetPickupLocationByOrderId.php | 11 ++++------- .../SaveOrderPickupLocation.php | 4 ++-- .../Order/GetPickupLocationForOrderPlugin.php | 14 ++++++-------- .../Order/SavePickupLocationForOrderPlugin.php | 8 ++++---- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/GetPickupLocationByOrderId.php b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/GetPickupLocationByOrderId.php index 2d5101e81f5e..307b0bc7fe7b 100644 --- a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/GetPickupLocationByOrderId.php +++ b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/GetPickupLocationByOrderId.php @@ -14,7 +14,8 @@ */ class GetPickupLocationByOrderId { - private const ORDER_ID = 'order_id'; + private const ORDER_ID = 'order_id'; + private const PICKUP_LOCATION_CODE = 'pickup_location_code'; /** @@ -23,8 +24,6 @@ class GetPickupLocationByOrderId private $connection; /** - * GetPickupLocationByOrderId constructor. - * * @param \Magento\Framework\App\ResourceConnection $connection */ public function __construct( @@ -40,15 +39,13 @@ public function __construct( * * @return string|null */ - public function execute(int $orderId):?string + public function execute(int $orderId): ?string { $connection = $this->connection->getConnection(); $table = $this->connection->getTableName('inventory_pickup_location_order'); $select = $connection->select() - ->from($table, [ - self::PICKUP_LOCATION_CODE => self::PICKUP_LOCATION_CODE - ]) + ->from($table, [self::PICKUP_LOCATION_CODE => self::PICKUP_LOCATION_CODE]) ->where(self::ORDER_ID . '= ?', $orderId) ->limit(1); diff --git a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/SaveOrderPickupLocation.php b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/SaveOrderPickupLocation.php index 96765931c7ed..15b07555f4e1 100644 --- a/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/SaveOrderPickupLocation.php +++ b/app/code/Magento/InventoryInStorePickup/Model/ResourceModel/OrderPickupLocation/SaveOrderPickupLocation.php @@ -14,7 +14,7 @@ */ class SaveOrderPickupLocation { - private const ORDER_ID = 'order_id'; + private const ORDER_ID = 'order_id'; private const PICKUP_LOCATION_CODE = 'pickup_location_code'; /** @@ -41,7 +41,7 @@ public function __construct( * * @return void */ - public function execute(int $orderId, string $pickupLocationCode):void + public function execute(int $orderId, string $pickupLocationCode): void { $connection = $this->connection->getConnection(); $table = $this->connection->getTableName('inventory_pickup_location_order'); diff --git a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupLocationForOrderPlugin.php b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupLocationForOrderPlugin.php index 1194ee4ede84..fa34698bcebc 100644 --- a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupLocationForOrderPlugin.php +++ b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/GetPickupLocationForOrderPlugin.php @@ -28,9 +28,7 @@ class GetPickupLocationForOrderPlugin private $getPickupLocationByOrderId; /** - * GetPickupLocationForOrderPlugin constructor. - * - * @param OrderExtensionFactory $orderExtensionFactory + * @param OrderExtensionFactory $orderExtensionFactory * @param GetPickupLocationByOrderId $getPickupLocationByOrderId */ public function __construct( @@ -42,16 +40,16 @@ public function __construct( } /** + * Add Pickup Location Code extension attribute when loading Order with OrderRepository. + * * @param OrderRepositoryInterface $orderRepository - * @param OrderInterface $order + * @param OrderInterface $order * * @return OrderInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterGet( - OrderRepositoryInterface $orderRepository, - OrderInterface $order - ):OrderInterface { + public function afterGet(OrderRepositoryInterface $orderRepository, OrderInterface $order): OrderInterface + { $extension = $order->getExtensionAttributes(); if (empty($extension)) { diff --git a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupLocationForOrderPlugin.php b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupLocationForOrderPlugin.php index 80fe5e8970eb..a0c163d4631c 100644 --- a/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupLocationForOrderPlugin.php +++ b/app/code/Magento/InventoryInStorePickup/Plugin/Sales/Order/SavePickupLocationForOrderPlugin.php @@ -22,8 +22,6 @@ class SavePickupLocationForOrderPlugin private $saveOrderPickupLocation; /** - * SavePickupLocationForOrderPlugin constructor. - * * @param SaveOrderPickupLocation $saveOrderPickupLocation */ public function __construct(SaveOrderPickupLocation $saveOrderPickupLocation) @@ -32,9 +30,11 @@ public function __construct(SaveOrderPickupLocation $saveOrderPickupLocation) } /** + * Save Order to Pickup Location relation when saving the order. + * * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Magento\Sales\Api\Data\OrderInterface $result - * @param \Magento\Sales\Api\Data\OrderInterface $entity + * @param \Magento\Sales\Api\Data\OrderInterface $result + * @param \Magento\Sales\Api\Data\OrderInterface $entity * * @return \Magento\Sales\Api\Data\OrderInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter)