<?php
/**
 * @author Aitoc Team
 * @copyright Copyright (c) 2020 Aitoc (https://www.aitoc.com)
 * @package Aitoc_PreOrders
 */

/**
 * Copyright © 2018 Aitoc. All rights reserved.
 * Developed by Alex Yakimovich
 */

namespace Aitoc\PreOrders\Plugin\CatalogInventory\Model\ResourceModel\Stock;

use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection as CatalogSearchFulltextCollection;

/**
 * Class Status
 */
class Status
{
    /**
     * @param mixed $subject
     * @param midex $result
     * @return mixed
     */
    public function afterAddStockDataToCollection(
        $subject,
        $result
    ) {
        if ($result instanceof CatalogSearchFulltextCollection) {
            $result->getSelect()->reset('where');
            /**
             * TODO: pre-order status validation
             */
        }
        return $result;
    }
}
