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/Label/Model/Label/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/app/code/Amasty/Label/Model/Label/GetMatchedProductIds.php
<?php

declare(strict_types=1);

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

namespace Amasty\Label\Model\Label;

use Amasty\Label\Api\Data\LabelInterface;
use Amasty\Label\Model\ResourceModel\Label\GetRelatedEntitiesIds as GetStoreIdsByLabelId;
use Amasty\Label\Model\RuleFactory;
use Magento\Framework\App\Area;
use Magento\Framework\App\State;

class GetMatchedProductIds implements GetMatchedProductIdsInterface
{
    /**
     * @var GetStoreIdsByLabelId
     */
    private $getStoreIdsByLabelId;

    /**
     * @var RuleFactory
     */
    private $ruleFactory;

    /**
     * @var State
     */
    private $appState;

    public function __construct(
        GetStoreIdsByLabelId $getStoreIdsByLabelId,
        RuleFactory $ruleFactory,
        State $appState
    ) {
        $this->getStoreIdsByLabelId = $getStoreIdsByLabelId;
        $this->ruleFactory = $ruleFactory;
        $this->appState = $appState;
    }

    public function executeWrapper(LabelInterface $label, ?array $productIds): array
    {
        return $this->appState->emulateAreaCode(
            Area::AREA_FRONTEND,
            [$this, 'execute'],
            [$label, $productIds]
        );
    }

    /**
     * @param LabelInterface $label
     * @param array|null $productIds
     *
     * @return int[]
     */
    public function execute(LabelInterface $label, ?array $productIds): array
    {
        $labelStores = $this->getLabelStoreIds($label->getLabelId());
        /** @var \Amasty\Label\Model\Rule $ruleModel */
        $ruleModel = $this->ruleFactory->create();
        $ruleModel->setConditions([]);
        $ruleModel->setStores($labelStores);
        $ruleModel->setConditionsSerialized($label->getConditionSerialized());

        if (!empty($productIds)) {
            $ruleModel->setProductFilter($productIds);
        }

        return $ruleModel->getMatchingProductIdsByLabel($label);
    }

    private function getLabelStoreIds(int $labelId): string
    {
        $storeIds = $this->getStoreIdsByLabelId->execute($labelId);

        return join(',', $storeIds);
    }
}

Spamworldpro Mini