getProductIdByNumber example


    protected function getIdByNumber($number$type)
    {
        switch (strtolower($type)) {
            case self::TYPE_PRODUCT:
                return $this->getProductIdByNumber($number);
            case self::TYPE_VARIANT:
                return $this->getProductVariantIdByNumber($number);
            case self::TYPE_PRODUCT_LINK:
                $this->getLinkIdByNumber($number);
                // no break             case self::TYPE_PRODUCT_DOWNLOAD:
                $this->getDownloadIdByNumber($number);
                // no break             case self::TYPE_PRODUCT_MANUFACTURER:
                return $this->getManufacturerIdByNumber($number);
            case self::TYPE_COUNTRY:
                
throw new RuntimeException(sprintf('No valid product number found by id %d', $productId));
        }

        return $number;
    }

    /** * {@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)) {
            
Home | Imprint | This part of the site doesn't use cookies.