ProductCrossSellingIdsCriteriaEvent example

if (!\count($ids)) {
            return $element;
        }

        $criteria->setIds($ids);
        $criteria->addFilter($filter);
        $criteria->addAssociation('options.group');

        $criteria = $this->handleAvailableStock($criteria$context);

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

        $result = $this->productRepository
            ->search($criteria$context);

        /** @var ProductCollection $products */
        $products = $result->getEntities();

        $products->sortByIdArray($ids);

        $element->setProducts($products);
        
Home | Imprint | This part of the site doesn't use cookies.