ProductListingPreviewCriteriaEvent example

// now we have a mapping for "child => main variant"         if (empty($mapping)) {
            return $ids;
        }

        // filter inactive and not available variants         $criteria = new Criteria(array_values($mapping));
        $criteria->addFilter(new ProductAvailableFilter($context->getSalesChannel()->getId()));
        $this->handleAvailableStock($criteria$context);

        $this->eventDispatcher->dispatch(
            new ProductListingPreviewCriteriaEvent($criteria$context)
        );

        $available = $this->productRepository->searchIds($criteria$context);

        $remapped = [];
        // replace existing ids with main variant id         foreach ($ids as $id) {
            // id has no mapped main_variant - keep old id             if (!isset($mapping[$id])) {
                $remapped[$id] = $id;

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