extractNumbers example

/* * Returns an array which is associated with the different product numbers. * Each array contains a list of product numbers which are related to the reference product. */
        $numbers = $this->gateway->getList($products);

        /* * Loads the list product data for the selected numbers. * All numbers are joined in the `extractNumbers` function to prevent that a product will be loaded multiple times */
        $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,
                
/* * Returns an array which is associated with the different product numbers. * Each array contains a list of product numbers which are related to the reference product. */
        $numbers = $this->gateway->getList($products$context);

        /* * Loads the list product data for the selected numbers. * All numbers are joined in the `extractNumbers` function to prevent that a product will be loaded multiple times */
        $similarProducts = $this->listProductService->getList(
            $this->extractNumbers($numbers),
            $context
        );

        $result = [];
        $fallback = [];

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

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