getProductsForListing example



    /** * Returns a single row with (almost) all possibly relevant information of a product * * @param int $detailId * * @return array<string, mixed>|null */
    public function getProductForListing($detailId)
    {
        $products = $this->getProductsForListing([$detailId]);

        return array_shift($products);
    }

    /** * Returns a multiple row with (almost) all possibly relevant information of products * * @param array<int> $ids * * @return array<array<string, mixed>> */
    
'value' => 1,
            ];
        }

        $repository = $this->container->get(ProductRepository::class);

        $result = $repository->search($criteria);

        $ids = array_column($result->getData(), 'variantId');

        $data = $this->container->get('multi_edit.product.dql_helper')
            ->getProductsForListing($ids);

        $sortedData = [];
        foreach ($ids as $id) {
            foreach ($data as $key => $row) {
                if ($row['Detail_id'] == $id) {
                    $sortedData[] = $row;
                    unset($data[$key]);
                    break;
                }
            }
        }

        

    public function filter($tokens$offset$limit$orderBy)
    {
        $query = $this->getFilterQuery($tokens$offset$limit$orderBy);
        list($result$totalCount) = $this->getPaginatedResult($query);

        $products = $this->getDqlHelper()->getProductsForListing($result);

        $sortedData = [];
        foreach ($result as $id) {
            foreach ($products as $key => $row) {
                if ($row['Detail_id'] == $id) {
                    $sortedData[] = $row;
                    unset($products[$key]);
                    break;
                }
            }
        }

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