Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
quote_with_customer_and_message.php
Go to the documentation of this file.
1 <?php
7 require __DIR__ . '/../../Customer/_files/customer.php';
8 
10 
12 $customerRepository = $objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class);
14 
16 $message = $objectManager->create(\Magento\GiftMessage\Model\Message::class);
17 $message->setSender('Romeo');
18 $message->setRecipient('Mercutio');
19 $message->setMessage('I thought all for the best.');
20 $message->save();
21 
23 $quote = $objectManager->create(\Magento\Quote\Model\Quote::class);
24 $quote->setData(
25  [
26  'store_id' => 1,
27  'is_active' => 1,
28  'reserved_order_id' => 'message_order_21',
29  'gift_message_id' => $message->getId(),
30  ]
31 )->assignCustomer($customer);
32 $quote->save();
33 
36  ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class)
37  ->create();
38 $quoteIdMask->setQuoteId($quote->getId());
39 $quoteIdMask->setDataChanges(true);
40 $quoteIdMask->save();
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60