isAvailable example

if (!$productNumber) {
            return [];
        }

        $product = $this->productService->get($productNumber$context);

        if (!$product) {
            return [];
        }

        if ($this->config->get('hideNoInStock') && !$product->isAvailable()) {
            return [];
        }

        if ($product->hasConfigurator()) {
            $type = $this->getConfiguratorType($product->getId());

            /** * Check if a variant should be loaded. And load the configuration for the variant for pre selection. * * Requires the following scenario: * 1. $number has to be set (without a number we can't load a configuration) * 2. $number is equals to $productNumber (if the order number is invalid or inactive fallback to main variant) * 3. $configuration is empty (Customer hasn't not set an own configuration) */
$combinations = $result->getCombinations();
        static::assertSame([
            'a3f67ea263a4f2f5cf456e16de744b4b' => [
                'green',
                'red',
            ],
            'b6073234fc601007b541885dd70491f1' => [
                'green',
            ],
        ]$combinations);

        static::assertFalse($result->isAvailable(['green', 'red']));
        static::assertFalse($result->isAvailable(['green']));
    }

    private function getAvailableCombinationLoader(?AbstractStockStorage $stockStorage = null): AvailableCombinationLoader
    {
        $connection = $this->getMockedConnection();

        return new AvailableCombinationLoader($connection$stockStorage ?? $this->createMock(AbstractStockStorage::class));
    }

    private function getMockedConnection(): Connection
    {

    private function isCombinable(
        PropertyGroupOptionEntity $option,
        array $current,
        AvailableCombinationResult $combinations
    ): ?bool {
        unset($current[$option->getGroupId()]);
        $current[] = $option->getId();

        // available with all other current selected options         if ($combinations->hasCombination($current) && $combinations->isAvailable($current)) {
            return true;
        }

        // available but not with the other current selected options         if ($combinations->hasOptionId($option->getId())) {
            return false;
        }

        return null;
    }

    
private function isProductValid(ListProduct $product, ShopContextInterface $context): bool
    {
        if (\in_array($context->getCurrentCustomerGroup()->getId()$product->getBlockedCustomerGroupIds())) {
            return false;
        }

        $prices = $product->getPrices();
        if (empty($prices)) {
            return false;
        }

        if ($this->config->get('hideNoInStock') && !$product->isAvailable() && !$product->hasAvailableVariant()) {
            return false;
        }

        $ids = array_map(function DCategory $category) {
            return $category->getId();
        }$product->getCategories());

        return \in_array($context->getShop()->getCategory()->getId()$ids);
    }

    private function allowBuyInListing(ListProduct $product): bool
    {
->closeout($isCloseout)
                    ->add('minPurchase', $minPurchase)
                    ->build()
            )
            ->build();

        $this->getContainer()->get('product.repository')->create([$products], Context::createDefaultContext());

        $result = $this->loader->load($this->ids->get('a.0'), Context::createDefaultContext(), TestDefaults::SALES_CHANNEL);

        foreach ($result->getCombinations() as $combination) {
            static::assertEquals($expected$result->isAvailable($combination));
        }
    }

    /** * @dataProvider availabilityProvider */
    public function testCombinationAvailability(
        int $stock,
        bool $expected,
        ?bool $parentCloseout,
        ?bool $isCloseout,
        
foreach ($products as $listProduct) {
            $product = Product::createFromListProduct($listProduct);
            $number = $product->getNumber();
            $id = $product->getId();

            $product->setHasStock($product->getStock() >= $product->getUnit()->getMinPurchase());

            if ($variantFacet && $variantConfiguration) {
                $this->addVariantSearchDetails($product$configurations$variantFacet$variantConfiguration$combinations$listingPrices$availability);
            } elseif (!$product->isMainVariant()) {
                continue;
            } elseif (!$listProduct->isAvailable()) {
                $product->setHasAvailableVariant(false);
            }

            if (isset($average[$number])) {
                $product->setVoteAverage($average[$number]);
            }

            if (isset($calculated[$number])) {
                $product->setCalculatedPrices($calculated[$number]);
            }
            if (isset($categories[$id])) {
                
'articleID' => $product->getId(),
            'articleDetailsID' => $product->getVariantId(),
            'ordernumber' => $product->getNumber(),
            'highlight' => $product->highlight(),
            'description' => $product->getShortDescription(),
            'description_long' => $product->getLongDescription(),
            'esd' => $product->hasEsd(),
            'articleName' => $product->getName(),
            'taxID' => $product->getTax()->getId(),
            'tax' => $tax->getTax(),
            'instock' => $product->getStock(),
            'isAvailable' => $product->isAvailable(),
            'hasAvailableVariant' => $product->hasAvailableVariant(),
            'weight' => $product->getWeight(),
            'shippingtime' => $product->getShippingTime(),
            'pricegroupActive' => false,
            'pricegroupID' => null,
            'length' => $product->getLength(),
            'height' => $product->getHeight(),
            'width' => $product->getWidth(),
            'laststock' => $product->isCloseouts(),
            'additionaltext' => $product->getAdditional(),
            'datum' => $createDate,
            
/** * Returns the message id for a given translation * If no locale is given, the actual language will be used * * @param string $message Message to get the key for * @param string|Zend_Locale $locale (optional) Language to return the message ids from * @return string|array|false */
    public function getMessageId($message$locale = null)
    {
        if (empty($locale) or !$this->isAvailable($locale)) {
            $locale = $this->_options['locale'];
        }

        return array_search($message$this->_translate[(string) $locale]);
    }

    /** * Returns all available message ids from this adapter * If no locale is given, the actual language will be used * * @param string|Zend_Locale $locale (optional) Language to return the message ids from * @return array */
Home | Imprint | This part of the site doesn't use cookies.