Skip to content

Commit

Permalink
removed dependency on App from frontend-api package
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmannmartin committed Aug 15, 2024
1 parent 2481674 commit 6d85dc0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/config/services_frontend_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ services:
Shopsys\FrontendApiBundle\Model\Order\OrderRepository:
alias: App\FrontendApi\Model\Order\OrderRepository

Shopsys\FrontendApiBundle\Model\Order\PlaceOrderFacade:
alias: App\FrontendApi\Model\Order\PlaceOrderFacade

Shopsys\FrontendApiBundle\Model\Parameter\ParameterWithValuesFactory:
alias: App\FrontendApi\Model\Parameter\ParameterWithValuesFactory

Expand Down Expand Up @@ -118,3 +115,7 @@ services:
Shopsys\FrontendApiBundle\Model\Resolver\Products\ProductsQuery:
alias: App\FrontendApi\Resolver\Products\ProductsQuery
public: true

Shopsys\FrontendApiBundle\Model\Resolver\Products\BestsellingProductsQuery:
alias: App\FrontendApi\Resolver\Products\BestsellingProductsQuery
public: true
34 changes: 34 additions & 0 deletions app/src/FrontendApi/Resolver/Products/BestsellingProductsQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace App\FrontendApi\Resolver\Products;

use App\Model\CategorySeo\ReadyCategorySeoMix;
use GraphQL\Executor\Promise\Promise;
use Shopsys\FrameworkBundle\Model\Category\Category;
use Shopsys\FrontendApiBundle\Model\Resolver\Products\BestsellingProductsQuery as BaseBestsellingProductsQuery;

class BestsellingProductsQuery extends BaseBestsellingProductsQuery
{
/**
* @param \App\Model\Category\Category|\App\Model\CategorySeo\ReadyCategorySeoMix $categoryOrReadyCategorySeoMix
* @return \GraphQL\Executor\Promise\Promise
*/
public function bestSellingProductsByCategoryOrReadyCategorySeoMixQuery(
Category|ReadyCategorySeoMix $categoryOrReadyCategorySeoMix,
): Promise {
$category = $categoryOrReadyCategorySeoMix instanceof ReadyCategorySeoMix
? $categoryOrReadyCategorySeoMix->getCategory()
: $categoryOrReadyCategorySeoMix;

$bestsellingProductsIds = $this->cachedBestsellingProductFacade->getOfferedBestsellingProductIds(
$this->domain->getId(),
$category,
$this->currentCustomerUser->getPricingGroup(),
$this->productFrontendLimitProvider->getProductsFrontendLimit(),
);

return $this->productsSellableByIdsBatchLoader->load($bestsellingProductsIds);
}
}

0 comments on commit 6d85dc0

Please sign in to comment.