-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from psihius/master
Out Of Memory for for attribute filters
- Loading branch information
Showing
6 changed files
with
100 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace BitBag\SyliusElasticsearchPlugin\EntityRepository; | ||
|
||
use Doctrine\ORM\QueryBuilder; | ||
use Sylius\Bundle\ProductBundle\Doctrine\ORM\ProductAttributeValueRepository as BaseRepository; | ||
use Sylius\Component\Attribute\Model\AttributeInterface; | ||
use Sylius\Component\Product\Model\ProductAttributeValueInterface; | ||
|
||
class ProductAttributeRepository implements ProductAttributeValueRepositoryInterface | ||
{ | ||
|
||
/** | ||
* @var BaseRepository | ||
*/ | ||
protected $repository; | ||
|
||
public function __construct(BaseRepository $repository) | ||
{ | ||
$this->repository = $repository; | ||
} | ||
|
||
/** | ||
* @param AttributeInterface $productAttribute | ||
* | ||
* @return array|ProductAttributeValueInterface[] | ||
*/ | ||
public function getUniqueAttributeValues(AttributeInterface $productAttribute): array | ||
{ | ||
/** @var QueryBuilder $queryBuilder */ | ||
$queryBuilder = $this->repository->createQueryBuilder('o'); | ||
|
||
return $queryBuilder | ||
->where('o.attribute = :attribute') | ||
->groupBy('o.'.$productAttribute->getStorageType()) | ||
->setParameter(':attribute', $productAttribute) | ||
->getQuery() | ||
->getResult(); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/EntityRepository/ProductAttributeValueRepositoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace BitBag\SyliusElasticsearchPlugin\EntityRepository; | ||
|
||
use Sylius\Component\Attribute\Model\AttributeInterface; | ||
use Sylius\Component\Product\Model\ProductAttributeValueInterface; | ||
|
||
interface ProductAttributeValueRepositoryInterface | ||
{ | ||
|
||
/** | ||
* @param AttributeInterface $productAttribute | ||
* | ||
* @return array|ProductAttributeValueInterface[] | ||
*/ | ||
public function getUniqueAttributeValues(AttributeInterface $productAttribute): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters