isProductAvailableInShop example

/** * {@inheritdoc} */
    public function getAvailableNumber($number, ShopContextInterface $context$selection = [])
    {
        $productId = $this->getProductIdByNumber($number);

        if ($productId === 0) {
            throw new RuntimeException(sprintf('No valid product id found for product with number "%s"', $number));
        }

        if (!$this->isProductAvailableInShop($productId$context->getShop())) {
            throw new RuntimeException(sprintf('Product with number "%s" is not available in current shop', $number));
        }

        $selected = '';
        if (!empty($selection)) {
            $selected = $this->getNumberBySelection($productId$selection);
        }

        if ($selected !== '') {
            return $selected;
        }

        
Home | Imprint | This part of the site doesn't use cookies.