resource = $resource; $this->groupConcatMaxLen = $groupConcatMaxLen; } /** * @inheritdoc */ public function execute(): void { $connection = $this->resource->getConnection(); $reservationTable = $this->resource->getTableName('inventory_reservation'); $select = $connection->select() ->from( $reservationTable, ['GROUP_CONCAT(' . ReservationInterface::RESERVATION_ID . ')'] ) ->group([ReservationInterface::STOCK_ID, ReservationInterface::SKU]) ->having('SUM(' . ReservationInterface::QUANTITY . ') = 0'); $connection->query('SET group_concat_max_len = ' . $this->groupConcatMaxLen); $groupedReservationIds = implode(',', $connection->fetchCol($select)); $condition = [ReservationInterface::RESERVATION_ID . ' IN (?)' => explode(',', $groupedReservationIds)]; $connection->delete($reservationTable, $condition); } }