Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /** * Copyright Magento, Inc. All rights reserved. * See COPYING.txt for license ..

Decoded Output download

<?php
/**
 * Copyright  Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Bundle\Plugin\Catalog\ViewModel\Product;

use Magento\Catalog\Model\Product;
use Magento\Catalog\ViewModel\Product\OptionsData as Subject;
use Magento\Catalog\Model\Product\Type;
use Magento\Bundle\Model\Product\SingleChoiceProvider;

/**
 * Plugin to add bundle options data
 */
class AddBundleOptionsData
{
    /**
     * @var SingleChoiceProvider
     */
    private $singleChoiceProvider;

    /**
     * @param SingleChoiceProvider $singleChoiceProvider
     */
    public function __construct(
        SingleChoiceProvider $singleChoiceProvider
    ) {
        $this->singleChoiceProvider = $singleChoiceProvider;
    }

    public function afterGetOptionsData(Subject $subject, array $result, Product $product) : array
    {
        if ($product->getTypeId() === Type::TYPE_BUNDLE) {
            if ($this->singleChoiceProvider->isSingleChoiceAvailable($product) === true) {
                $typeInstance = $product->getTypeInstance();
                $typeInstance->setStoreFilter($product->getStoreId(), $product);
                $options = $typeInstance->getOptions($product);
                foreach ($options as $option) {
                    $optionId = $option->getId();
                    $selectionsCollection = $typeInstance->getSelectionsCollection(
                        [$optionId],
                        $product
                    );
                    $selections = $selectionsCollection->exportToArray();
                    $countSelections = count($selections);
                    foreach ($selections as $selection) {
                        $name = 'bundle_option[' . $optionId . ']';
                        if ($countSelections > 1) {
                            $name .= '[]';
                        }
                        $result[] = [
                            'name' => $name,
                            'value' => $selection['selection_id']
                        ];
                    }
                }
            }
        }
        return $result;
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php
/**
 * Copyright  Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Bundle\Plugin\Catalog\ViewModel\Product;

use Magento\Catalog\Model\Product;
use Magento\Catalog\ViewModel\Product\OptionsData as Subject;
use Magento\Catalog\Model\Product\Type;
use Magento\Bundle\Model\Product\SingleChoiceProvider;

/**
 * Plugin to add bundle options data
 */
class AddBundleOptionsData
{
    /**
     * @var SingleChoiceProvider
     */
    private $singleChoiceProvider;

    /**
     * @param SingleChoiceProvider $singleChoiceProvider
     */
    public function __construct(
        SingleChoiceProvider $singleChoiceProvider
    ) {
        $this->singleChoiceProvider = $singleChoiceProvider;
    }

    public function afterGetOptionsData(Subject $subject, array $result, Product $product) : array
    {
        if ($product->getTypeId() === Type::TYPE_BUNDLE) {
            if ($this->singleChoiceProvider->isSingleChoiceAvailable($product) === true) {
                $typeInstance = $product->getTypeInstance();
                $typeInstance->setStoreFilter($product->getStoreId(), $product);
                $options = $typeInstance->getOptions($product);
                foreach ($options as $option) {
                    $optionId = $option->getId();
                    $selectionsCollection = $typeInstance->getSelectionsCollection(
                        [$optionId],
                        $product
                    );
                    $selections = $selectionsCollection->exportToArray();
                    $countSelections = count($selections);
                    foreach ($selections as $selection) {
                        $name = 'bundle_option[' . $optionId . ']';
                        if ($countSelections > 1) {
                            $name .= '[]';
                        }
                        $result[] = [
                            'name' => $name,
                            'value' => $selection['selection_id']
                        ];
                    }
                }
            }
        }
        return $result;
    }
}

Function Calls

None

Variables

None

Stats

MD5 f114876adbf1fada35ef3370b6b0baf3
Eval Count 0
Decode Time 147 ms