Skip to content

Commit

Permalink
last visited products (#2716)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitek-rostislav authored Jan 23, 2024
2 parents f32090e + 245b97d commit 5c352c8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Model/Resolver/Products/ProductsQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Shopsys\FrameworkBundle\Model\Product\List\ProductList;
use Shopsys\FrameworkBundle\Model\Product\List\ProductListFacade;
use Shopsys\FrameworkBundle\Model\Product\Listing\ProductListOrderingConfig;
use Shopsys\FrameworkBundle\Model\Product\ProductRepository;
use Shopsys\FrontendApiBundle\Model\Product\Connection\ProductConnectionFactory;
use Shopsys\FrontendApiBundle\Model\Product\Filter\ProductFilterFacade;
use Shopsys\FrontendApiBundle\Model\Product\ProductFacade;
Expand All @@ -27,13 +28,15 @@ class ProductsQuery extends AbstractQuery
* @param \Shopsys\FrontendApiBundle\Model\Product\Connection\ProductConnectionFactory $productConnectionFactory
* @param \Overblog\DataLoader\DataLoaderInterface $productsVisibleAndSortedByIdsBatchLoader
* @param \Shopsys\FrameworkBundle\Model\Product\List\ProductListFacade $productListFacade
* @param \Shopsys\FrameworkBundle\Model\Product\ProductRepository $productRepository
*/
public function __construct(
protected readonly ProductFacade $productFacade,
protected readonly ProductFilterFacade $productFilterFacade,
protected readonly ProductConnectionFactory $productConnectionFactory,
protected readonly DataLoaderInterface $productsVisibleAndSortedByIdsBatchLoader,
protected readonly ProductListFacade $productListFacade,
protected readonly ProductRepository $productRepository,
) {
}

Expand Down Expand Up @@ -183,4 +186,15 @@ public function productsByProductListQuery(ProductList $productList): Promise

return $this->productsVisibleAndSortedByIdsBatchLoader->load($productIds);
}

/**
* @param string[] $catnums
* @return \GraphQL\Executor\Promise\Promise
*/
public function productsByCatnumsQuery(array $catnums): Promise
{
$productIds = $this->productRepository->getProductIdsByCatnums($catnums);

return $this->productsVisibleAndSortedByIdsBatchLoader->load($productIds);
}
}
8 changes: 8 additions & 0 deletions src/Resources/config/graphql-types/QueryDecorator.types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,11 @@ QueryDecorator:
type: '[BlogCategory!]!'
resolve: "@=query('blogCategoriesQuery')"
description: "Returns a complete list of the blog categories"
productsByCatnums:
type: "[Product!]!"
resolve: '@=query("productsByCatnumsQuery", args["catnums"])'
args:
catnums:
type: "[String!]!"
description: "Array of product catalog numbers"
description: "Returns list of products by catalog numbers"

0 comments on commit 5c352c8

Please sign in to comment.