[Solved] ShopContext in ProductStream API

    private function getProductStream($categoryID)
    {
        $category = Shopware()->Models()->getRepository('Shopware\Models\Category\Category')->find($categoryID);
        $criteria = new Criteria();
        $criteria->addBaseCondition(new CategoryCondition([$categoryID]));
        $criteria->offset(0)->limit(100);

        /** @var RepositoryInterface $streamRepository */
        $streamRepository = Shopware()->Container()->get('shopware_product_stream.repository');
        $streamRepository->prepareCriteria($criteria, $category->getStream());

        /** @var ProductSearchResult $result */
        $repository = Shopware()->Models()->getRepository('Shopware\Models\Shop\Shop');
        $shop = $repository->getActiveDefault();
        $context = Shopware()->Container()->get('shopware_storefront.context_service')->getShopContext();

        $result = Shopware()->Container()->get('shopware_search.product_search')->search($criteria, $context);
        error_log("test");

        $count = $result->getTotalCount();
        return $count;
    }

 

Ich bin gerade dabei eine ProductStream API zu bauen und stelle gerade fest das wenn ich die SuchFunktion aus dem Shopware verwenden möchte einen ShopKontext brauche.

Irgednwie schaffe ich es das nicht zu umgeben, jemand eine Idee?