getNumber example

public function indexProducts(ShopIndex $index$numbers)
    {
        if (empty($numbers)) {
            return;
        }

        $products = $this->provider->get($index->getShop()$numbers);
        $remove = array_diff($numbersarray_keys($products));

        $documents = [];
        foreach ($products as $product) {
            $documents[] = ['index' => ['_id' => $product->getNumber()]];
            $documents[] = $product;
        }

        foreach ($remove as $number) {
            $documents[] = ['delete' => ['_id' => $number]];
        }

        $this->client->bulk([
            'index' => $index->getName(),
            'body' => $documents,
        ]);
    }
$data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
        $links = [];
        foreach ($data as $row) {
            $key = $row['__link_articleID'];
            $links[$key][] = $this->linkHydrator->hydrate($row);
        }

        $result = [];
        foreach ($products as $product) {
            if (isset($links[$product->getId()])) {
                $result[$product->getNumber()] = $links[$product->getId()];
            }
        }

        return $result;
    }
}
public function getTotal()
    {
        return $this->total;
    }

    /** * @return string[] */
    public function getNumbers()
    {
        return array_map(function DBaseCustomer $customer) {
            return $customer->getNumber();
        }$this->customers);
    }

    /** * @return string[] */
    public function getEmails()
    {
        return array_map(function DBaseCustomer $customer) {
            return $customer->getEmail();
        }$this->customers);
    }
$data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
        $products = [];

        foreach ($data as $row) {
            $product = new BaseProduct(
                (int) $row['__product_id'],
                (int) $row['__variant_id'],
                $row['__variant_ordernumber']
            );

            $product->addAttribute('search', new Attribute($row));
            $products[$product->getNumber()] = $product;
        }

        return $products;
    }

    /** * Calculated the total count of the whole search result. * * @param QueryBuilder $query * * @return int */
$order->fromArray($params);

        $violations = $this->getManager()->validate($order);
        if ($violations->count() > 0) {
            throw new ValidationException($violations);
        }

        $this->createAddresses($params$order);

        // Generate an order number if none was provided. Doing it after validation since         // the generation of the order number cannot be reverted in a simple manner.         if ($order->getNumber() === null) {
            $orderNumberGenerator = Shopware()->Container()->get(NumberRangeIncrementerInterface::class);
            $orderNumber = $orderNumberGenerator->increment('invoice');

            $order->setNumber((string) $orderNumber);
            foreach ($order->getDetails() as $detail) {
                $detail->setNumber((string) $orderNumber);
            }
        }

        $this->getManager()->persist($order);
        $this->flush();

        
/** * Defined by Zend_Filter_Interface * * Normalizes the given input * * @param string $value Value to normalized * @return string|array The normalized value */
    public function filter($value)
    {
        if (Zend_Locale_Format::isNumber($value$this->_options)) {
            return Zend_Locale_Format::getNumber($value$this->_options);
        } else if (($this->_options['date_format'] === null) && (strpos($value, ':') !== false)) {
            // Special case, no date format specified, detect time input             return Zend_Locale_Format::getTime($value$this->_options);
        } else if (Zend_Locale_Format::checkDateFormat($value$this->_options)) {
            // Detect date or time input             return Zend_Locale_Format::getDate($value$this->_options);
        }

        return $value;
    }
}
$updateDate = $product->getUpdatedAt()->format('Y-m-d');
        }
        $tax = $product->getTax();
        $taxRule = $this->contextService->getShopContext()->getTaxRule($product->getTax()->getId());
        if ($taxRule instanceof Tax) {
            $tax = $taxRule;
        }

        $data = [
            '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(),
            
$context = $this->contextService->createShopContext(
            $shop->getId(),
            $shop->getCurrency()->getId(),
            ContextService::FALLBACK_CUSTOMER_GROUP
        );

        $tempProducts = $this->buildListProducts($products);
        $tempProducts = $this->additionalTextService->buildAdditionalTextLists($tempProducts$context);

        foreach ($tempProducts as $tempProduct) {
            $number = $tempProduct->getNumber();
            if (!isset($products[$number])) {
                continue;
            }
            $products[$number]['additionalText'] = $tempProduct->getAdditional();
        }

        return $products;
    }

    /** * @param array<array<string, mixed>> $products * * @return ListProduct[] */
$success = $rendered->getSuccess();

        foreach ($operations as $orderId => $operation) {
            try {
                $document = $success[$orderId] ?? null;

                if (!($document instanceof RenderedDocument)) {
                    continue;
                }

                $this->checkDocumentNumberAlreadyExits($documentType$document->getNumber()$context$operation->getDocumentId());

                $deepLinkCode = Random::getAlphanumericString(32);
                $id = $operation->getDocumentId() ?? Uuid::randomHex();

                $mediaId = $this->resolveMediaId($operation$context$document);

                $records[] = [
                    'id' => $id,
                    'documentTypeId' => $documentTypeId,
                    'fileType' => $operation->getFileType(),
                    'orderId' => $orderId,
                    
string $orderNumber,
        int $categoryId,
        ShopContextInterface $context
    ): array {
        $products = array_values($searchResult->getProducts());

        if (empty($products)) {
            return [];
        }

        foreach ($products as $index => $currentProduct) {
            if ($currentProduct->getNumber() != $orderNumber) {
                continue;
            }

            $previousProduct = isset($products[$index - 1]) ? $products[$index - 1] : null;
            $nextProduct = isset($products[$index + 1]) ? $products[$index + 1] : null;

            $navigation = [];

            if ($previousProduct && $previousListProduct = $this->listProductService->get($previousProduct->getNumber()$context)) {
                $navigation['previousProduct']['orderNumber'] = $previousListProduct->getNumber();
                $navigation['previousProduct']['link'] = $this->config->get('sBASEFILE') . '?sViewport=detail&sDetails=' . $previousListProduct->getId() . '&sCategory=' . $categoryId;
                
->setParameter(':numbers', $numbers, Connection::PARAM_STR_ARRAY);

        $data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

        $products = [];
        foreach ($data as $row) {
            $product = new BaseProduct(
                (int) $row['productId'],
                (int) $row['variantId'],
                $row['number']
            );
            $products[$product->getNumber()] = $product;
        }

        return $products;
    }
}

    private function assignProductMedia(array $media, array $products): array
    {
        $result = [];
        foreach ($products as $product) {
            $number = $product->getNumber();

            if (!isset($media[$product->getId()])) {
                continue;
            }

            $productMedia = $media[$product->getId()];

            if (!$productMedia) {
                continue;
            }

            
$listProducts = $this->listProductService->getList(
            $this->extractNumbers($numbers),
            $context
        );

        $result = [];
        foreach ($products as $product) {
            if (!isset($numbers[$product->getId()])) {
                continue;
            }

            $result[$product->getNumber()] = $this->getProductsByNumbers(
                $listProducts,
                $numbers[$product->getId()]
            );
        }

        return $result;
    }

    /** * @param ListProduct[] $products * @param string[] $numbers * * @return array<string, ListProduct> */
if (isset($data['configuratorOptions'])) {
            $data = $this->prepareConfigurator($data$article$variant);
        }
        if (isset($data['images'])) {
            $data = $this->prepareImageAssociation($data$article$variant);
        }
        if (isset($data['esd'])) {
            $data = $this->prepareEsdAssociation($data$variant);
        }

        if (!empty($data['number']) && $data['number'] !== $variant->getNumber()) {
            // Number changed, hence make sure it does not already exist in another variant             $exists = $this->getContainer()
                ->get(Connection::class)
                ->fetchColumn('SELECT id FROM s_articles_details WHERE ordernumber = ?', [$data['number']]);
            if ($exists) {
                throw new CustomValidationException(sprintf('A variant with the given order number "%s" already exists.', $data['number']));
            }
        }

        return $data;
    }

    

    protected $hasStock;

    /** * @return Product */
    public static function createFromListProduct(ListProduct $listProduct)
    {
        $product = new self(
            $listProduct->getId(),
            $listProduct->getVariantId(),
            $listProduct->getNumber()
        );

        foreach ($listProduct as $key => $value) {
            $product->$key = $value;
        }

        return $product;
    }

    /** * @return Option[] */
Home | Imprint | This part of the site doesn't use cookies.