![]() 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/Ecombricks/InventoryInventoryReservations/Plugin/Model/ResourceModel/ |
<?php /** * Copyright © eComBricks. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Ecombricks\InventoryInventoryReservations\Plugin\Model\ResourceModel; /** * Save multiple reservations resource plugin */ class SaveMultiple { /** * Resource connection * * @var \Magento\Framework\App\ResourceConnection */ protected $resourceConnection; /** * Constructor * * @param \Magento\Framework\App\ResourceConnection $resourceConnection * @return void */ public function __construct( \Magento\Framework\App\ResourceConnection $resourceConnection ) { $this->resourceConnection = $resourceConnection; } /** * Around execute * * @param \Magento\InventoryReservations\Model\ResourceModel\SaveMultiple $subject * @param \Closure $proceed * @param \Ecombricks\InventoryInventoryReservations\Model\ReservationInterface[] $reservations * @return void */ public function aroundExecute( \Magento\InventoryReservations\Model\ResourceModel\SaveMultiple $subject, \Closure $proceed, array $reservations ) { $data = []; foreach ($reservations as $reservation) { $data[] = [ $reservation->getSourceCode(), $reservation->getSku(), $reservation->getQuantity(), $reservation->getMetadata(), ]; } $this->resourceConnection->getConnection()->insertArray( $this->resourceConnection->getTableName('inventory_reservation'), [ \Ecombricks\InventoryInventoryReservations\Model\ReservationInterface::SOURCE_CODE, \Ecombricks\InventoryInventoryReservations\Model\ReservationInterface::SKU, \Ecombricks\InventoryInventoryReservations\Model\ReservationInterface::QUANTITY, \Ecombricks\InventoryInventoryReservations\Model\ReservationInterface::METADATA, ], $data ); } }