Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
order_with_multiple_items.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
8 require 'order.php';
12 
13 require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php';
15  'product_id' => $product->getId(),
16  'base_price' => 123,
17  'order_id' => $order->getId(),
18  'price' => 123,
19  'row_total' => 126,
20  'product_type' => 'simple'
21 ];
22 
23 require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_duplicated.php';
24 $orderItems[] = [
25  'product_id' => $product->getId(),
26  'base_price' => 123,
27  'order_id' => $order->getId(),
28  'price' => 123,
29  'row_total' => 126,
30  'product_type' => 'simple'
31 ];
32 
33 require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_with_full_option_set.php';
34 $orderItems[] = [
35  'product_id' => $product->getId(),
36  'base_price' => 123,
37  'order_id' => $order->getId(),
38  'price' => 123,
39  'row_total' => 126,
40  'product_type' => 'simple'
41 ];
42 
43 require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_with_url_key.php';
44 $orderItems[] = [
45  'product_id' => $product->getId(),
46  'base_price' => 123,
47  'order_id' => $order->getId(),
48  'price' => 123,
49  'row_total' => 126,
50  'product_type' => 'simple'
51 ];
52 
53 require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_with_all_fields.php';
54 $orderItems[] = [
55  'product_id' => $product->getId(),
56  'base_price' => 123,
57  'order_id' => $order->getId(),
58  'price' => 123,
59  'row_total' => 126,
60  'product_type' => 'simple'
61 ];
62 
63 require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_with_custom_attribute.php';
64 $orderItems[] = [
65  'product_id' => $product->getId(),
66  'base_price' => 123,
67  'order_id' => $order->getId(),
68  'price' => 123,
69  'row_total' => 126,
70  'product_type' => 'simple'
71 ];
72 
74 foreach ($orderItems as $orderItemData) {
77  \Magento\Sales\Model\Order\Item::class
78  );
80  ->setData($orderItemData)
81  ->save();
82 }
$orderItem
Definition: order.php:30
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
$order
Definition: order.php:55