<commit_before><?php

namespace Ekyna\Bundle\ProductBundle\Service\Updater;

use Ekyna\Bundle\ProductBundle\Model;
use Ekyna\Component\Commerce\Stock\Model\StockSubjectModes;
use Ekyna\Component\Commerce\Stock\Model\StockSubjectStates;

/**
 * Class ConfigurableUpdater
 * @package Ekyna\Bundle\ProductBundle\Updater
 * @author  <NAME> <<EMAIL>>
 */
class ConfigurableUpdater extends AbstractUpdater
{
    /**
     * @inheritdoc
     */
    public function updateMinPrice(Model\ProductInterface $bundle)
    {
        Model\ProductTypes::assertConfigurable($bundle);

        $minPrice = $this->priceCalculator->calculateConfigurableMinPrice($bundle);

        if (is_null($bundle->getMinPrice()) || 0 !== bccomp($bundle->getMinPrice(), $minPrice, 5)) {
            $bundle->setMinPrice($minPrice);

            return true;
        }

        return false;
    }

    /**
     * @inheritdoc
     */
    public function updateStock(Model\ProductInterface $bundle)
    {
        Model\ProductTypes::assertConfigurable($bundle);

        $disabled = true; $justInTime = true; $supplierPreOrder = true;
        $inStock = $virtualStock = $availableStock = $eda = null;

        // TODO Use packaging format

        $bundleSlots = $bundle->getBundleSlots()->getIterator();
        /** @var \Ekyna\Bundle\ProductBundle\Model\BundleSlotInterface $slot */
        if (0 < $bundleSlots->count()) {
            $slotsBestChoices = [];

            // Resolve best choice for each slots
            foreach ($bundleSlots as $slot) {
                /** @var \Ekyna\Bundle\ProductBundle\Model\BundleChoiceInterface $bestChoice */
                $bestChoice = null;

                foreach ($slot->getChoices() as $choice) {<commit_msg>[Product] Fixed configurable update (skip non required slots for stock update).<commit_after><?php

namespace Ekyna\Bundle\ProductBundle\Service\Updater;

use Ekyna\Bundle\ProductBundle\Model;
use Ekyna\Component\Commerce\Stock\Model\StockSubjectModes;
use Ekyna\Component\Commerce\Stock\Model\StockSubjectStates;

/**
 * Class ConfigurableUpdater
 * @package Ekyna\Bundle\ProductBundle\Updater
 * @author  <NAME> <<EMAIL>>
 */
class ConfigurableUpdater extends AbstractUpdater
{
    /**
     * @inheritdoc
     */
    public function updateMinPrice(Model\ProductInterface $bundle)
    {
        Model\ProductTypes::assertConfigurable($bundle);

        $minPrice = $this->priceCalculator->calculateConfigurableMinPrice($bundle);

        if (is_null($bundle->getMinPrice()) || 0 !== bccomp($bundle->getMinPrice(), $minPrice, 5)) {
            $bundle->setMinPrice($minPrice);

            return true;
        }

        return false;
    }

    /**
     * @inheritdoc
     */
    public function updateStock(Model\ProductInterface $bundle)
    {
        Model\ProductTypes::assertConfigurable($bundle);

        $disabled = true; $justInTime = true; $supplierPreOrder = true;
        $inStock = $virtualStock = $availableStock = $eda = null;

        // TODO Use packaging format

        $bundleSlots = $bundle->getBundleSlots()->getIterator();
        /** @var \Ekyna\Bundle\ProductBundle\Model\BundleSlotInterface $slot */
        if (0 < $bundleSlots->count()) {
            $slotsBestChoices = [];

            // Resolve best choice for each slots
            foreach ($bundleSlots as $slot) {
                /** @var \Ekyna\Bundle\ProductBundle\Model\BundleChoiceInterface $bestChoice */
                $bestChoice = null;

                if (!$slot->isRequired()) {
                    continue;
                }

                foreach ($slot->getChoices() as $choice) {
{'fraction_non_alphanumeric': 0.1262109050650429, 'fraction_numerical': 0.0016606698034874066, 'mean_word_length': 2.6839959225280325, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5381161', 'n_tokens_mistral': 1042, 'n_tokens_neox': 996, 'n_words': 189}