repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
icetalker/filament-table-repeater | https://github.com/icetalker/filament-table-repeater/blob/f633ecb3f54f3adc93f1e6a90a40dfe8bc03483a/tests/TestCase.php | tests/TestCase.php | <?php
namespace Icetalker\FilamentTableRepeater\Tests;
use Icetalker\FilamentTableRepeater\FilamentTableRepeaterServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use Orchestra\Testbench\TestCase as Orchestra;
class TestCase extends Orchestra
{
protected function setUp(): void
{
parent::setUp();
Factory::guessFactoryNamesUsing(
fn (string $modelName) => 'Icetalker\\FilamentTableRepeater\\Database\\Factories\\'.class_basename($modelName).'Factory'
);
}
protected function getPackageProviders($app)
{
return [
FilamentTableRepeaterServiceProvider::class,
];
}
public function getEnvironmentSetUp($app)
{
config()->set('database.default', 'testing');
/*
$migration = include __DIR__.'/../database/migrations/create_filament-table-repeater_table.php.stub';
$migration->up();
*/
}
}
| php | MIT | f633ecb3f54f3adc93f1e6a90a40dfe8bc03483a | 2026-01-05T05:15:40.280096Z | false |
icetalker/filament-table-repeater | https://github.com/icetalker/filament-table-repeater/blob/f633ecb3f54f3adc93f1e6a90a40dfe8bc03483a/tests/ExampleTest.php | tests/ExampleTest.php | <?php
it('can test', function () {
expect(true)->toBeTrue();
});
| php | MIT | f633ecb3f54f3adc93f1e6a90a40dfe8bc03483a | 2026-01-05T05:15:40.280096Z | false |
icetalker/filament-table-repeater | https://github.com/icetalker/filament-table-repeater/blob/f633ecb3f54f3adc93f1e6a90a40dfe8bc03483a/resources/views/table-repeater.blade.php | resources/views/table-repeater.blade.php | @php
use Filament\Support\Enums\Alignment;
@endphp
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
@php
$items = $getItems();
$addAction = $getAction($getAddActionName());
$addActionAlignment = $getAddActionAlignment();
$cloneAction = $getAction($getCloneActionName());
$deleteAction = $getAction($getDeleteActionName());
$moveDownAction = $getAction($getMoveDownActionName());
$moveUpAction = $getAction($getMoveUpActionName());
$reorderAction = $getAction($getReorderActionName());
$isAddable = $isAddable();
$isCloneable = $isCloneable();
$isCollapsible = $isCollapsible();//
$isDeletable = $isDeletable();
$isReorderable = $isReorderable();
$isReorderableWithButtons = $isReorderableWithButtons();
$isReorderableWithDragAndDrop = $isReorderableWithDragAndDrop();
$statePath = $getStatePath();
$columnLabels = $getColumnLabels();
$colStyles = $getColStyles();
//---
$addBetweenAction = $getAction($getAddBetweenActionName());//
$extraItemActions = $getExtraItemActions();
@endphp
<div
{{-- x-data="{ state: $wire.entangle('{{ $getStatePath() }}') }" --}}
x-data="{ isCollapsed: @js($isCollapsed()) }"
x-on:repeater-collapse.window="$event.detail === '{{ $getStatePath() }}' && (isCollapsed = true)"
x-on:repeater-expand.window="$event.detail === '{{ $getStatePath() }}' && (isCollapsed = false)"
{{
$attributes
->merge($getExtraAttributes(), escape: false)
->class(['it-table-repeater'])
}}
>
<div
class="it-table-repeater-header"
>
<div></div>
@if ($isCollapsible)
<div>
<button
x-on:click="isCollapsed = !isCollapsed"
type="button"
class="it-table-repeater-btn-collapse"
>
<x-heroicon-s-chevron-up class="w-4 h-4" x-show="! isCollapsed"/>
<span class="sr-only" x-show="! isCollapsed">
{{ __('filament-forms::components.repeater.actions.collapse.label') }}
</span>
<x-heroicon-s-chevron-down class="w-4 h-4" x-show="isCollapsed" x-cloak/>
<span class="sr-only" x-show="isCollapsed" x-cloak>
{{ __('filament-forms::components.repeater.actions.expand.label') }}
</span>
</button>
</div>
@endif
</div>
<div class="px-4{{ $isAddable? '' : ' py-2' }}">
<table x-show="! isCollapsed">
<thead>
<tr>
@foreach($columnLabels as $columnLabel)
@if($columnLabel['display'])
<th
@if($colStyles && isset($colStyles[$columnLabel['component']]))
style="{{ $colStyles[$columnLabel['component']] }}"
@endif
>
<span>
{{ $columnLabel['name'] }}
</span>
</th>
@else
<th class="hidden"></th>
@endif
@endforeach
@if (count($extraItemActions)||$isReorderableWithDragAndDrop || $isReorderableWithButtons || $isCloneable || $isDeletable)
<th></th>
@endif
</tr>
</thead>
<tbody
x-sortable
>
@foreach ($items as $itemKey => $item)
<tr
x-on:repeater-collapse.window="$event.detail === '{{ $getStatePath() }}' && (isCollapsed = true)"
x-on:repeater-expand.window="$event.detail === '{{ $getStatePath() }}' && (isCollapsed = false)"
wire:key="{{ $item->getLivewireKey() }}.item"
x-sortable-item="{{ $itemKey }}"
>
@foreach ($item->getComponents(withHidden: true) as $component)
<td>
{{ $component }}
</td>
@endforeach
@if (count($extraItemActions)||$isReorderableWithDragAndDrop || $isReorderableWithButtons || $isCloneable || $isDeletable )
<td class="it-table-repeater-actions">
@foreach ($extraItemActions as $extraItemAction)
<div x-on:click.stop>
{{ $extraItemAction(['item' => $itemKey]) }}
</div>
@endforeach
@if ($isReorderableWithDragAndDrop || $isReorderableWithButtons)
@if ($isReorderableWithDragAndDrop)
<div
x-sortable-handle
x-on:click.stop
>
{{ $reorderAction }}
</div>
@endif
@if ($isReorderableWithButtons)
<div
class="flex items-center justify-center"
>
{{ $moveUpAction(['item' => $itemKey])->disabled($loop->first) }}
</div>
<div
class="flex items-center justify-center"
>
{{ $moveDownAction(['item' => $itemKey])->disabled($loop->last) }}
</div>
@endif
@endif
@if ($isCloneable || $isDeletable )
@if ($cloneAction->isVisible())
<div>
{{ $cloneAction(['item' => $itemKey]) }}
</div>
@endif
@if ($isDeletable)
<div>
{{ $deleteAction(['item' => $itemKey]) }}
</div>
@endif
@endif
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
<div class="it-table-repeater-collapsed" x-show="isCollapsed" x-cloak>
{{ __('filament-table-repeater::components.table-repeater.collapsed') }}
</div>
</div>
@if ($isAddable && $addAction->isVisible())
<div
@class([
'it-table-repeater-add',
match ($addActionAlignment) {
Alignment::Start, Alignment::Left => 'justify-start',
Alignment::Center, null => 'justify-center',
Alignment::End, Alignment::Right => 'justify-end',
default => $alignment,
},
])
>
{{ $addAction }}
</div>
@endif
</div>
</x-dynamic-component>
| php | MIT | f633ecb3f54f3adc93f1e6a90a40dfe8bc03483a | 2026-01-05T05:15:40.280096Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/ecs.php | ecs.php | <?php
declare(strict_types=1);
use Symplify\EasyCodingStandard\Config\ECSConfig;
return static function (ECSConfig $config): void {
putenv('ALLOW_BITBAG_OS_HEADER=1');
$config->import('vendor/bitbag/coding-standard/ecs.php');
$config->paths(['src', 'tests']);
};
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/BitBagSyliusElasticsearchPlugin.php | src/BitBagSyliusElasticsearchPlugin.php | <?php
/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin;
use BitBag\SyliusElasticsearchPlugin\CompilerPass\AuthenticationManagerPolyfillPass;
use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
final class BitBagSyliusElasticsearchPlugin extends Bundle
{
use SyliusPluginTrait;
public function getPath(): string
{
return \dirname(__DIR__);
}
public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new AuthenticationManagerPolyfillPass());
parent::build($container);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Model/ProductVariantTrait.php | src/Model/ProductVariantTrait.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Model;
use Sylius\Component\Core\Model\ProductInterface;
trait ProductVariantTrait
{
public function getProduct(): ProductInterface
{
$product = parent::getProduct();
$product->addVariant($this);
return $product;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Model/SearchBox.php | src/Model/SearchBox.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Model;
class SearchBox
{
private ?string $query = null;
public function getQuery(): ?string
{
return $this->query;
}
public function setQuery(?string $query): void
{
$this->query = $query;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Model/ProductVariantInterface.php | src/Model/ProductVariantInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Model;
use Sylius\Component\Core\Model\ProductInterface;
interface ProductVariantInterface
{
public function getProduct(): ProductInterface;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Model/SearchFacets.php | src/Model/SearchFacets.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Model;
use Iterator;
final class SearchFacets implements Iterator
{
private array $selectedBuckets = [];
public function __get(string $facetId): array
{
if (!array_key_exists($facetId, $this->selectedBuckets)) {
return [];
}
return $this->selectedBuckets[$facetId];
}
public function __set(string $facetId, string $selectedBuckets): void
{
$this->selectedBuckets[$facetId] = $selectedBuckets;
}
public function __isset(string $facetId)
{
return true;
}
/**
* @inheritdoc
*/
public function current(): mixed
{
return current($this->selectedBuckets);
}
/**
* @inheritdoc
*/
public function next(): void
{
next($this->selectedBuckets);
}
/**
* @inheritdoc
*/
public function key(): mixed
{
return key($this->selectedBuckets);
}
/**
* @inheritdoc
*/
public function valid(): bool
{
$key = key($this->selectedBuckets);
return null !== $key;
}
/**
* @inheritdoc
*/
public function rewind(): void
{
reset($this->selectedBuckets);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Model/Search.php | src/Model/Search.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Model;
final class Search
{
private ?string $query = null;
private array $facets = [];
public function getQuery(): ?string
{
return $this->query;
}
public function setQuery(?string $query): void
{
$this->query = $query;
}
public function getFacets(): array
{
return $this->facets;
}
public function setFacets(array $facets): void
{
$this->facets = $facets;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Formatter/StringFormatterInterface.php | src/Formatter/StringFormatterInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Formatter;
interface StringFormatterInterface
{
public function formatToLowercaseWithoutSpaces(string $input): string;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Formatter/StringFormatter.php | src/Formatter/StringFormatter.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Formatter;
final class StringFormatter implements StringFormatterInterface
{
public function formatToLowercaseWithoutSpaces(string $input): string
{
return mb_strtolower(str_replace([' ', '-'], '_', $input));
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Facet/PriceFacet.php | src/Facet/PriceFacet.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\Histogram;
use Elastica\Query\AbstractQuery;
use Elastica\Query\BoolQuery;
use Elastica\Query\Range;
use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface;
use Sylius\Component\Core\Context\ShopperContextInterface;
final class PriceFacet implements FacetInterface
{
public const FACET_ID = 'price';
public function __construct(
private ConcatedNameResolverInterface $channelPricingNameResolver,
private MoneyFormatterInterface $moneyFormatter,
private ShopperContextInterface $shopperContext,
private int $interval
) {
}
public function getAggregation(): AbstractAggregation
{
$priceFieldName = $this->channelPricingNameResolver->resolvePropertyName(
(string) $this->shopperContext->getChannel()->getCode()
);
$histogram = new Histogram(self::FACET_ID, $priceFieldName, $this->interval);
$histogram->setMinimumDocumentCount(1);
return $histogram;
}
public function getQuery(array $selectedBuckets): AbstractQuery
{
$priceFieldName = $this->channelPricingNameResolver->resolvePropertyName(
(string) $this->shopperContext->getChannel()->getCode()
);
$query = new BoolQuery();
foreach ($selectedBuckets as $selectedBucket) {
$query->addShould(
new Range($priceFieldName, ['gte' => $selectedBucket, 'lte' => $selectedBucket + $this->interval])
);
}
return $query;
}
public function getBucketLabel(array $bucket): string
{
$from = $this->moneyFormatter->format(
(int) $bucket['key'],
$this->shopperContext->getCurrencyCode(),
$this->shopperContext->getLocaleCode()
);
$to = $this->moneyFormatter->format(
(int) ($bucket['key'] + $this->interval),
$this->shopperContext->getCurrencyCode(),
$this->shopperContext->getLocaleCode()
);
return sprintf('%s - %s (%s)', $from, $to, $bucket['doc_count']);
}
public function getLabel(): string
{
return 'bitbag_sylius_elasticsearch_plugin.ui.facet.price.label';
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Facet/AutoDiscoverRegistry.php | src/Facet/AutoDiscoverRegistry.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use BitBag\SyliusElasticsearchPlugin\Repository\ProductAttributeRepositoryInterface;
use BitBag\SyliusElasticsearchPlugin\Repository\ProductOptionRepositoryInterface;
use Sylius\Component\Attribute\Model\AttributeInterface;
use Sylius\Component\Locale\Context\LocaleContextInterface;
use Sylius\Component\Product\Model\ProductOptionInterface;
final class AutoDiscoverRegistry implements AutoDiscoverRegistryInterface
{
/** @var FacetInterface[] */
private array $facets = [];
public function __construct(
private bool $autoRegister,
private ProductAttributeRepositoryInterface $productAttributeRepository,
private ProductOptionRepositoryInterface $productOptionRepository,
private ConcatedNameResolverInterface $attributeNameResolver,
private ConcatedNameResolverInterface $optionNameResolver,
private LocaleContextInterface $localeContext,
private RegistryInterface $registry,
private array $excludedAttributes = [],
private array $excludedOptions = []
) {
}
public function autoRegister(): void
{
if (false === $this->autoRegister || [] !== $this->facets) {
return;
}
$this->discoverAttributes();
$this->discoverOptions();
foreach ($this->facets as $facetId => $facet) {
$this->registry->addFacet((string) $facetId, $facet);
}
}
private function discoverAttributes(): void
{
$attributes = $this->productAttributeRepository->findAllWithTranslations($this->localeContext->getLocaleCode());
/** @var AttributeInterface $attribute */
foreach ($attributes as $attribute) {
$code = $attribute->getCode();
if (in_array($code, $this->excludedAttributes, true)) {
continue;
}
$this->facets[$code] = new AttributeFacet(
$this->attributeNameResolver,
$attribute,
$this->localeContext,
);
}
}
private function discoverOptions(): void
{
$options = $this->productOptionRepository->findAllWithTranslations($this->localeContext->getLocaleCode());
/** @var ProductOptionInterface $option */
foreach ($options as $option) {
$code = $option->getCode();
if (in_array($code, $this->excludedOptions, true)) {
continue;
}
$this->facets[$code] = new OptionFacet(
$this->optionNameResolver,
$option,
);
}
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Facet/TaxonFacet.php | src/Facet/TaxonFacet.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\Terms;
use Elastica\Query\AbstractQuery;
use Elastica\Query\Terms as TermsQuery;
use Sylius\Component\Core\Model\Taxon;
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
final class TaxonFacet implements FacetInterface
{
public const FACET_ID = 'taxon';
public function __construct(
private TaxonRepositoryInterface $taxonRepository,
private string $taxonsPropertyName
) {
}
public function getAggregation(): AbstractAggregation
{
$terms = new Terms(self::FACET_ID);
$terms->setField($this->getField());
return $terms;
}
public function getQuery(array $selectedBuckets): AbstractQuery
{
return new TermsQuery($this->getField(), $selectedBuckets);
}
public function getBucketLabel(array $bucket): string
{
$label = $taxonCode = $bucket['key'];
$taxon = $this->taxonRepository->findOneBy(['code' => $taxonCode]);
if ($taxon instanceof Taxon) {
$label = $taxon->getName();
}
return sprintf('%s (%s)', $label, $bucket['doc_count']);
}
private function getField(): string
{
return $this->taxonsPropertyName . '.keyword';
}
public function getLabel(): string
{
return 'bitbag_sylius_elasticsearch_plugin.ui.facet.taxon.label';
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Facet/Registry.php | src/Facet/Registry.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
final class Registry implements RegistryInterface
{
/** @var FacetInterface[] */
private array $facets = [];
public function addFacet(string $facetId, FacetInterface $facet): void
{
$this->facets[$facetId] = $facet;
}
/**
* @return FacetInterface[]
*/
public function getFacets(): array
{
return $this->facets;
}
public function getFacetById(string $facetId): FacetInterface
{
if (!array_key_exists($facetId, $this->facets)) {
throw new FacetNotFoundException(sprintf('Cannot find facet with ID "%s" in registry.', $facetId));
}
return $this->facets[$facetId];
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Facet/FacetNotFoundException.php | src/Facet/FacetNotFoundException.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
class FacetNotFoundException extends \RuntimeException
{
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Facet/AttributeFacet.php | src/Facet/AttributeFacet.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\Terms;
use Elastica\Query\AbstractQuery;
use Elastica\Query\Terms as TermsQuery;
use function sprintf;
use Sylius\Component\Attribute\AttributeType\CheckboxAttributeType;
use Sylius\Component\Attribute\AttributeType\FloatAttributeType;
use Sylius\Component\Attribute\AttributeType\IntegerAttributeType;
use Sylius\Component\Attribute\AttributeType\PercentAttributeType;
use Sylius\Component\Attribute\Model\AttributeInterface;
use Sylius\Component\Locale\Context\LocaleContextInterface;
final class AttributeFacet implements FacetInterface
{
public function __construct(
private ConcatedNameResolverInterface $attributeNameResolver,
private AttributeInterface $attribute,
private LocaleContextInterface $localeContext
) {
}
public function getAggregation(): AbstractAggregation
{
$aggregation = new Terms('');
$aggregation->setField($this->getFieldName());
return $aggregation;
}
public function getQuery(array $selectedBuckets): AbstractQuery
{
match ($this->getProductAttribute()->getType()) {
CheckboxAttributeType::TYPE => $selectedBuckets = array_map('boolval', $selectedBuckets),
PercentAttributeType::TYPE,
FloatAttributeType::TYPE => $selectedBuckets = array_map('floatval', $selectedBuckets),
IntegerAttributeType::TYPE => $selectedBuckets = array_map('intval', $selectedBuckets),
default => $selectedBuckets,
};
return new TermsQuery($this->getFieldName(), $selectedBuckets);
}
public function getBucketLabel(array $bucket): string
{
$label = ucwords(str_replace('_', ' ', (string) $bucket['key']));
return sprintf('%s (%s)', $label, $bucket['doc_count']);
}
public function getLabel(): string
{
return (string) $this->getProductAttribute()->getName();
}
private function getFieldName(): string
{
$isKeywordAvailable = match ($this->getProductAttribute()->getType()) {
CheckboxAttributeType::TYPE,
PercentAttributeType::TYPE,
FloatAttributeType::TYPE,
IntegerAttributeType::TYPE => false,
default => true,
};
return sprintf(
'%s_%s' . ($isKeywordAvailable ? '.keyword' : ''),
$this->attributeNameResolver->resolvePropertyName((string) $this->getProductAttribute()->getCode()),
$this->localeContext->getLocaleCode()
);
}
private function getProductAttribute(): AttributeInterface
{
return $this->attribute;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Facet/RegistryInterface.php | src/Facet/RegistryInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
interface RegistryInterface
{
public function addFacet(string $facetId, FacetInterface $facet): void;
/**
* @return FacetInterface[]
*/
public function getFacets(): array;
public function getFacetById(string $facetId): FacetInterface;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Facet/OptionFacet.php | src/Facet/OptionFacet.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\Terms;
use Elastica\Query\AbstractQuery;
use Elastica\Query\Terms as TermsQuery;
use Sylius\Component\Product\Model\ProductOptionInterface;
final class OptionFacet implements FacetInterface
{
public function __construct(
private ConcatedNameResolverInterface $optionNameResolver,
private ProductOptionInterface $productOption,
) {
}
public function getAggregation(): AbstractAggregation
{
$aggregation = new Terms('');
$aggregation->setField($this->getFieldName());
return $aggregation;
}
public function getQuery(array $selectedBuckets): AbstractQuery
{
return new TermsQuery($this->getFieldName(), $selectedBuckets);
}
public function getBucketLabel(array $bucket): string
{
$label = ucwords(str_replace('_', ' ', $bucket['key']));
return sprintf('%s (%s)', $label, $bucket['doc_count']);
}
public function getLabel(): string
{
return (string) $this->productOption->getName();
}
private function getFieldName(): string
{
return $this->optionNameResolver->resolvePropertyName((string) $this->productOption->getCode()) . '.keyword';
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Facet/AutoDiscoverRegistryInterface.php | src/Facet/AutoDiscoverRegistryInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
interface AutoDiscoverRegistryInterface
{
public function autoRegister(): void;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Facet/FacetInterface.php | src/Facet/FacetInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Facet;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Query\AbstractQuery;
interface FacetInterface
{
public function getAggregation(): AbstractAggregation;
public function getQuery(array $selectedBuckets): AbstractQuery;
public function getBucketLabel(array $bucket): string;
public function getLabel(): string;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Finder/ProductOptionsFinderInterface.php | src/Finder/ProductOptionsFinderInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use Sylius\Component\Core\Model\TaxonInterface;
interface ProductOptionsFinderInterface
{
public function findByTaxon(TaxonInterface $taxon): ?array;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Finder/NamedProductsFinder.php | src/Finder/NamedProductsFinder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
use Elastica\Query\AbstractQuery;
use FOS\ElasticaBundle\Finder\FinderInterface;
final class NamedProductsFinder implements NamedProductsFinderInterface
{
public function __construct(
private QueryBuilderInterface $queryBuilder,
private FinderInterface $productsFinder
) {
}
public function findByNamePart(string $namePart): ?array
{
$data = ['query' => $namePart];
/** @var AbstractQuery $query */
$query = $this->queryBuilder->buildQuery($data);
return $this->productsFinder->find($query);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Finder/ProductAttributesFinderInterface.php | src/Finder/ProductAttributesFinderInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use Sylius\Component\Core\Model\TaxonInterface;
interface ProductAttributesFinderInterface
{
public function findByTaxon(TaxonInterface $taxon): ?array;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Finder/ProductOptionsFinder.php | src/Finder/ProductOptionsFinder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
use Elastica\Query\AbstractQuery;
use FOS\ElasticaBundle\Finder\FinderInterface;
use Sylius\Component\Core\Model\TaxonInterface;
final class ProductOptionsFinder implements ProductOptionsFinderInterface
{
public function __construct(
private FinderInterface $optionsFinder,
private QueryBuilderInterface $productOptionsByTaxonQueryBuilder,
private string $taxonsProperty,
private int $filterMax = 20
) {
}
public function findByTaxon(TaxonInterface $taxon): ?array
{
$data = [];
$data[$this->taxonsProperty] = strtolower((string) $taxon->getCode());
/** @var AbstractQuery $query */
$query = $this->productOptionsByTaxonQueryBuilder->buildQuery($data);
return $this->optionsFinder->find($query, $this->filterMax);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Finder/ShopProductsFinderInterface.php | src/Finder/ShopProductsFinderInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use Pagerfanta\Pagerfanta;
interface ShopProductsFinderInterface
{
public function find(array $data): Pagerfanta;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Finder/ProductAttributesFinder.php | src/Finder/ProductAttributesFinder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
use Elastica\Query\AbstractQuery;
use FOS\ElasticaBundle\Finder\FinderInterface;
use Sylius\Component\Core\Model\TaxonInterface;
final class ProductAttributesFinder implements ProductAttributesFinderInterface
{
public function __construct(
private FinderInterface $attributesFinder,
private QueryBuilderInterface $attributesByTaxonQueryBuilder,
private string $taxonsProperty,
private int $filterMax = 20,
) {
}
public function findByTaxon(TaxonInterface $taxon): ?array
{
$data = [];
$data[$this->taxonsProperty] = strtolower((string) $taxon->getCode());
/** @var AbstractQuery $query */
$query = $this->attributesByTaxonQueryBuilder->buildQuery($data);
return $this->attributesFinder->find($query, $this->filterMax);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Finder/NamedProductsFinderInterface.php | src/Finder/NamedProductsFinderInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
interface NamedProductsFinderInterface
{
public function findByNamePart(string $namePart): ?array;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Finder/ShopProductsFinder.php | src/Finder/ShopProductsFinder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Finder;
use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\PaginationDataHandlerInterface;
use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\SortDataHandlerInterface;
use BitBag\SyliusElasticsearchPlugin\Facet\RegistryInterface;
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
use Elastica\Query;
use FOS\ElasticaBundle\Finder\PaginatedFinderInterface;
use Pagerfanta\Pagerfanta;
final class ShopProductsFinder implements ShopProductsFinderInterface
{
public function __construct(
private QueryBuilderInterface $queryBuilder,
private PaginatedFinderInterface $productFinder,
private RegistryInterface $facetRegistry
) {
}
public function find(array $data): Pagerfanta
{
/** @var Query\BoolQuery $boolQuery */
$boolQuery = $this->queryBuilder->buildQuery($data);
if (array_key_exists('facets', $data) && is_array($data['facets'])) {
foreach ($data['facets'] as $facetId => $selectedBuckets) {
if (!$selectedBuckets) {
continue;
}
$facet = $this->facetRegistry->getFacetById((string) $facetId);
$boolQuery->addFilter($facet->getQuery($selectedBuckets));
}
}
$query = new Query($boolQuery);
if (array_key_exists(SortDataHandlerInterface::SORT_INDEX, $data)) {
$query->addSort($data[SortDataHandlerInterface::SORT_INDEX]);
}
$products = $this->productFinder->findPaginated($query);
if (null !== $data[PaginationDataHandlerInterface::LIMIT_INDEX]) {
$products->setMaxPerPage($data[PaginationDataHandlerInterface::LIMIT_INDEX]);
}
if (null !== $data[PaginationDataHandlerInterface::PAGE_INDEX]) {
$products->setCurrentPage($data[PaginationDataHandlerInterface::PAGE_INDEX]);
}
return $products;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/RequestDataHandler/PaginationDataHandlerInterface.php | src/Controller/RequestDataHandler/PaginationDataHandlerInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
interface PaginationDataHandlerInterface extends DataHandlerInterface
{
public const PAGE_INDEX = 'page';
public const LIMIT_INDEX = 'limit';
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/RequestDataHandler/ShopProductsSortDataHandler.php | src/Controller/RequestDataHandler/ShopProductsSortDataHandler.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use Sylius\Component\Channel\Context\ChannelContextInterface;
use UnexpectedValueException;
final class ShopProductsSortDataHandler implements SortDataHandlerInterface
{
public function __construct(
private ConcatedNameResolverInterface $channelPricingNameResolver,
private ChannelContextInterface $channelContext,
private string $soldUnitsProperty,
private string $createdAtProperty,
private string $pricePropertyPrefix
) {
}
public function retrieveData(array $requestData): array
{
$data = [];
$orderBy = $requestData[self::ORDER_BY_INDEX] ?? $this->createdAtProperty;
$sort = $requestData[self::SORT_INDEX] ?? self::SORT_ASC_INDEX;
$availableSorters = [$this->soldUnitsProperty, $this->createdAtProperty, $this->pricePropertyPrefix];
$availableSorting = [self::SORT_ASC_INDEX, self::SORT_DESC_INDEX];
if (!in_array($orderBy, $availableSorters, true) || !in_array($sort, $availableSorting, true)) {
throw new UnexpectedValueException();
}
if ($this->pricePropertyPrefix === $orderBy) {
/** @var string $channelCode */
$channelCode = $this->channelContext->getChannel()->getCode();
$orderBy = $this->channelPricingNameResolver->resolvePropertyName($channelCode);
}
$data['sort'] = [$orderBy => ['order' => strtolower($sort), 'unmapped_type' => 'keyword']];
return $data;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/RequestDataHandler/PaginationDataHandler.php | src/Controller/RequestDataHandler/PaginationDataHandler.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
final class PaginationDataHandler implements PaginationDataHandlerInterface
{
public function __construct(
private int $defaultLimit
) {
}
public function retrieveData(array $requestData): array
{
$data = [];
$this->resolvePage($requestData, $data);
$this->resolveLimit($requestData, $data);
return $data;
}
private function resolvePage(array $requestData, array &$data): void
{
$page = 1;
if (isset($requestData[self::PAGE_INDEX])) {
$page = (int) $requestData[self::PAGE_INDEX];
}
$data[self::PAGE_INDEX] = $page;
}
private function resolveLimit(array $requestData, array &$data): void
{
$limit = $this->defaultLimit;
if (isset($requestData[self::LIMIT_INDEX])) {
$limit = (int) $requestData[self::LIMIT_INDEX];
}
$data[self::LIMIT_INDEX] = $limit;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/RequestDataHandler/SiteWideDataHandler.php | src/Controller/RequestDataHandler/SiteWideDataHandler.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
final class SiteWideDataHandler implements DataHandlerInterface
{
public function __construct(
private DataHandlerInterface $sortDataHandler,
private DataHandlerInterface $paginationDataHandler,
) {
}
public function retrieveData(array $requestData): array
{
return array_merge(
$this->sortDataHandler->retrieveData($requestData),
$this->paginationDataHandler->retrieveData($requestData)
);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/RequestDataHandler/TaxonDataHandler.php | src/Controller/RequestDataHandler/TaxonDataHandler.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
final class TaxonDataHandler implements DataHandlerInterface
{
public function __construct(
private DataHandlerInterface $shopProductListDataHandler,
private SortDataHandlerInterface $shopProductsSortDataHandler,
private PaginationDataHandlerInterface $paginationDataHandler
) {
}
public function retrieveData(array $requestData): array
{
return array_merge(
$this->shopProductListDataHandler->retrieveData($requestData),
$this->shopProductsSortDataHandler->retrieveData($requestData),
$this->paginationDataHandler->retrieveData($requestData)
);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/RequestDataHandler/SortDataHandlerInterface.php | src/Controller/RequestDataHandler/SortDataHandlerInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
interface SortDataHandlerInterface extends DataHandlerInterface
{
public const ORDER_BY_INDEX = 'order_by';
public const SORT_INDEX = 'sort';
public const SORT_ASC_INDEX = 'asc';
public const SORT_DESC_INDEX = 'desc';
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/RequestDataHandler/ShopProductListDataHandler.php | src/Controller/RequestDataHandler/ShopProductListDataHandler.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
use BitBag\SyliusElasticsearchPlugin\Context\TaxonContextInterface;
use BitBag\SyliusElasticsearchPlugin\Finder\ProductAttributesFinderInterface;
use Sylius\Component\Attribute\AttributeType\CheckboxAttributeType;
use Sylius\Component\Attribute\AttributeType\IntegerAttributeType;
use Sylius\Component\Product\Model\ProductAttribute;
final class ShopProductListDataHandler implements DataHandlerInterface
{
public function __construct(
private TaxonContextInterface $taxonContext,
private ProductAttributesFinderInterface $attributesFinder,
private string $namePropertyPrefix,
private string $taxonsProperty,
private string $optionPropertyPrefix,
private string $attributePropertyPrefix
) {
}
public function retrieveData(array $requestData): array
{
$data = [];
$taxon = $this->taxonContext->getTaxon();
$data[$this->namePropertyPrefix] = (string) $requestData[$this->namePropertyPrefix];
$data[$this->taxonsProperty] = strtolower((string) $taxon->getCode());
$data['taxon'] = $taxon;
$data = array_merge(
$data,
$requestData['price'] ?? [],
['facets' => $requestData['facets'] ?? []],
);
$attributesDefinitions = $this->attributesFinder->findByTaxon($taxon);
$this->handleOptionsPrefixedProperty($requestData, $data);
$this->handleAttributesPrefixedProperty($requestData, $data, $attributesDefinitions);
return $data;
}
private function handleOptionsPrefixedProperty(
array $requestData,
array &$data
): void {
if (!isset($requestData['options'])) {
return;
}
foreach ($requestData['options'] as $key => $value) {
if (is_array($value) && 0 === strpos($key, $this->optionPropertyPrefix)) {
$data[$key] = array_map(function (string $property): string {
return strtolower($property);
}, $value);
}
}
}
private function handleAttributesPrefixedProperty(
array $requestData,
array &$data,
?array $attributesDefinitions = []
): void {
if (!isset($requestData['attributes'])) {
return;
}
$attributeTypes = $this->getAttributeTypes((array) $attributesDefinitions);
foreach ($requestData['attributes'] as $key => $value) {
if (!is_array($value) || 0 !== strpos($key, $this->attributePropertyPrefix)) {
continue;
}
$data[$key] = $this->reformatAttributeArrayValues($value, $key, $attributeTypes);
}
}
private function getAttributeTypes(array $attributesDefinitions): array
{
$data = [];
/** @var ProductAttribute $attributesDefinition */
foreach ($attributesDefinitions as $attributesDefinition) {
$data['attribute_' . $attributesDefinition->getCode()] = $attributesDefinition->getType();
}
return $data;
}
private function reformatAttributeArrayValues(
array $attributeValues,
string $property,
array $attributesDefinitions
): array {
$reformattedValues = [];
foreach ($attributeValues as $attributeValue) {
switch ($attributesDefinitions[$property]) {
case CheckboxAttributeType::TYPE:
$value = (bool) ($attributeValue);
break;
case IntegerAttributeType::TYPE:
$value = (float) ($attributeValue);
break;
default:
$value = strtolower($attributeValue);
}
$reformattedValues[] = $value;
}
return $reformattedValues;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/RequestDataHandler/DataHandlerInterface.php | src/Controller/RequestDataHandler/DataHandlerInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
interface DataHandlerInterface
{
public function retrieveData(array $requestData): array;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/Response/ItemsResponse.php | src/Controller/Response/ItemsResponse.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\Response;
use BitBag\SyliusElasticsearchPlugin\Controller\Response\DTO\Item;
final class ItemsResponse
{
private function __construct(
/** @var $items array|Item[] */
private array $items
) {
}
public static function createEmpty(): self
{
return new self([]);
}
public function addItem(DTO\Item $item): void
{
$this->items[] = $item;
}
public function all(): \Traversable
{
foreach ($this->items as $item) {
yield $item->toArray();
}
}
public function toArray(): array
{
return ['items' => iterator_to_array($this->all())];
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/Response/DTO/Item.php | src/Controller/Response/DTO/Item.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\Response\DTO;
final class Item
{
private string $taxonName;
private string $name;
private ?string $description;
private string $slug;
private ?string $price;
private ?string $image;
public function __construct(
string $taxonName,
string $name,
?string $description,
string $slug,
?string $price,
?string $image
) {
$this->taxonName = $taxonName;
$this->name = $name;
$this->description = $description;
$this->slug = $slug;
$this->price = $price;
$this->image = $image;
}
public function taxonName(): string
{
return $this->taxonName;
}
public function name(): string
{
return $this->name;
}
public function description(): ?string
{
return $this->description;
}
public function slug(): string
{
return $this->slug;
}
public function price(): ?string
{
return $this->price;
}
public function image(): ?string
{
return $this->image;
}
public function toArray(): array
{
return [
'taxon_name' => $this->taxonName(),
'name' => $this->name(),
'description' => $this->description() ?? '',
'slug' => $this->slug(),
'price' => $this->price(),
'image' => $this->image() ?? '',
];
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/Action/Shop/TaxonProductsSearchAction.php | src/Controller/Action/Shop/TaxonProductsSearchAction.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\Action\Shop;
use BitBag\SyliusElasticsearchPlugin\Form\Type\ShopProductsFilterType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
final class TaxonProductsSearchAction extends AbstractSearchAction
{
public function __invoke(Request $request): Response
{
$template = $request->get('template');
$form = $this->formFactory->create(ShopProductsFilterType::class);
$form->handleRequest($request);
$requestData = array_merge(
$form->getData(),
$request->query->all(),
['slug' => $request->get('slug')]
);
if ($form->isSubmitted() && !$form->isValid()) {
$requestData = $this->clearInvalidEntries($form, $requestData);
}
$data = $this->dataHandler->retrieveData($requestData);
$products = $this->finder->find($data);
return new Response($this->twig->render($template, [
'form' => $form->createView(),
'products' => $products,
'taxon' => $data['taxon'] ?? null,
]));
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/Action/Shop/AbstractSearchAction.php | src/Controller/Action/Shop/AbstractSearchAction.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\Action\Shop;
use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\DataHandlerInterface;
use BitBag\SyliusElasticsearchPlugin\Finder\ShopProductsFinderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Twig\Environment;
abstract class AbstractSearchAction
{
public function __construct(
protected FormFactoryInterface $formFactory,
protected DataHandlerInterface $dataHandler,
protected ShopProductsFinderInterface $finder,
protected Environment $twig
) {
}
protected function clearInvalidEntries(FormInterface $form, array $requestData): array
{
/** @var FormError $error */
foreach ($form->getErrors(true) as $error) {
/** @var FormInterface $errorOrigin */
$errorOrigin = $error->getOrigin();
/** @var FormInterface $parent */
$parent = $errorOrigin->getParent();
$path = ($parent->getPropertyPath() ?? '') . $errorOrigin->getPropertyPath();
$keys = explode('][', trim($path, '[]'));
$dataRef = &$requestData;
foreach ($keys as $index => $key) {
if (isset($dataRef[$key])) {
if ($index === count($keys) - 1) {
unset($dataRef[$key]);
} else {
$dataRef = &$dataRef[$key];
}
}
}
}
return $requestData;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/Action/Shop/SiteWideProductsSearchAction.php | src/Controller/Action/Shop/SiteWideProductsSearchAction.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\Action\Shop;
use BitBag\SyliusElasticsearchPlugin\Form\Type\SearchType;
use BitBag\SyliusElasticsearchPlugin\Model\Search;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
final class SiteWideProductsSearchAction extends AbstractSearchAction
{
public function __invoke(Request $request): Response
{
$template = $request->get('template', '@BitBagSyliusElasticsearchPlugin/Shop/search.html.twig');
$form = $this->formFactory->create(SearchType::class);
$form->handleRequest($request);
if ($form->isSubmitted()) {
/** @var Search $search */
$search = $form->getData();
$data = array_merge(
['query' => $search->getQuery()],
['facets' => $search->getFacets()],
$this->dataHandler->retrieveData($request->query->all()),
);
if (!$form->isValid()) {
$data = $this->clearInvalidEntries($form, $data);
}
$results = $this->finder->find($data);
}
return new Response($this->twig->render(
$template,
[
'products' => $results ?? null,
'resources' => $results ?? null,
'search_form' => $form->createView(),
]
));
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Controller/Action/Api/ListProductsByPartialNameAction.php | src/Controller/Action/Api/ListProductsByPartialNameAction.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Controller\Action\Api;
use BitBag\SyliusElasticsearchPlugin\Controller\Response\DTO\Item;
use BitBag\SyliusElasticsearchPlugin\Controller\Response\ItemsResponse;
use BitBag\SyliusElasticsearchPlugin\Finder\NamedProductsFinderInterface;
use BitBag\SyliusElasticsearchPlugin\Transformer\Product\TransformerInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
final class ListProductsByPartialNameAction
{
public function __construct(
private NamedProductsFinderInterface $namedProductsFinder,
private TransformerInterface $productSlugTransformer,
private TransformerInterface $productChannelPriceTransformer,
private TransformerInterface $productImageTransformer
) {
}
public function __invoke(Request $request): Response
{
$itemsResponse = ItemsResponse::createEmpty();
if (null === $request->query->get('query')) {
return new JsonResponse($itemsResponse->toArray());
}
/** @var array $products */
$products = $this->namedProductsFinder->findByNamePart((string) $request->query->get('query'));
/** @var ProductInterface $product */
foreach ($products as $product) {
if (null === $productMainTaxon = $product->getMainTaxon()) {
continue;
}
$itemsResponse->addItem(new Item(
(string) $productMainTaxon->getName(),
(string) $product->getName(),
$product->getShortDescription(),
(string) $this->productSlugTransformer->transform($product),
$this->productChannelPriceTransformer->transform($product),
$this->productImageTransformer->transform($product)
));
}
return new JsonResponse($itemsResponse->toArray());
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Twig/Extension/UnsetArrayElementsExtension.php | src/Twig/Extension/UnsetArrayElementsExtension.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Twig\Extension;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
final class UnsetArrayElementsExtension extends AbstractExtension
{
public function unsetElements(array $elements, array $keys): array
{
foreach ($keys as $key) {
if (!isset($elements[$key])) {
continue;
}
unset($elements[$key]);
}
return $elements;
}
public function getFilters(): array
{
return [
new TwigFilter('unset_elements', [$this, 'unsetElements']),
];
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Twig/Component/SearchFormComponent.php | src/Twig/Component/SearchFormComponent.php | <?php
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Twig\Component;
use BitBag\SyliusElasticsearchPlugin\Form\Type\SearchType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormView;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
use Symfony\UX\TwigComponent\Attribute\ExposeInTemplate;
#[AsTwigComponent]
final class SearchFormComponent
{
public function __construct(
private FormFactoryInterface $formFactory,
) {
}
#[ExposeInTemplate('search_form')]
public function searchForm(): FormView
{
return $this->formFactory->create(SearchType::class)->createView();
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/NameFilterType.php | src/Form/Type/NameFilterType.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\OptionsResolver\OptionsResolver;
final class NameFilterType extends AbstractFilterType
{
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
$resolver->setDefaults([
'label' => 'bitbag_sylius_elasticsearch_plugin.ui.name',
'required' => false,
]);
}
public function getParent(): string
{
return TextType::class;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/AbstractFilterType.php | src/Form/Type/AbstractFilterType.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
abstract class AbstractFilterType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class', null,
'csrf_protection' => false,
'allow_extra_fields' => true,
]);
}
public function getBlockPrefix(): string
{
return '';
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/SearchFacetsType.php | src/Form/Type/SearchFacetsType.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use BitBag\SyliusElasticsearchPlugin\Facet\RegistryInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
final class SearchFacetsType extends AbstractType
{
public function __construct(
private RegistryInterface $facetRegistry
) {
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
foreach ($options['facets'] as $facetId => $facetData) {
$facet = $this->facetRegistry->getFacetById((string) $facetId);
$choices = [];
foreach ($facetData['buckets'] as $bucket) {
$choices[$facet->getBucketLabel($bucket)] = $bucket['key'];
}
if ([] !== $choices) {
$builder
->add(
(string) $facetId,
ChoiceType::class,
[
'label' => $facet->getLabel(),
'choices' => $choices,
'expanded' => true,
'multiple' => true,
]
)
;
}
}
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setRequired('facets');
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/ShopProductsFilterType.php | src/Form/Type/ShopProductsFilterType.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use BitBag\SyliusElasticsearchPlugin\Facet\AutoDiscoverRegistryInterface;
use BitBag\SyliusElasticsearchPlugin\Form\EventSubscriber\AddFacetsEventSubscriber;
use BitBag\SyliusElasticsearchPlugin\Form\Resolver\ProductsFilterFacetResolverInterface;
use Symfony\Component\Form\FormBuilderInterface;
final class ShopProductsFilterType extends AbstractFilterType
{
public function __construct(
private AutoDiscoverRegistryInterface $autoDiscoverRegistry,
private string $namePropertyPrefix,
private ProductsFilterFacetResolverInterface $facetResolver
) {
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add($this->namePropertyPrefix, NameFilterType::class)
->add('price', PriceFilterType::class, ['required' => false, 'label' => false])
->setMethod('GET');
$builder->addEventSubscriber(new AddFacetsEventSubscriber(
$this->autoDiscoverRegistry,
$this->facetResolver,
$this->namePropertyPrefix
));
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/PriceFilterType.php | src/Form/Type/PriceFilterType.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\PriceNameResolverInterface;
use Sylius\Bundle\MoneyBundle\Form\Type\MoneyType;
use Sylius\Component\Currency\Context\CurrencyContextInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Validator\Constraints\LessThan;
use Symfony\Component\Validator\Constraints\PositiveOrZero;
use Symfony\Component\Validator\Constraints\Type;
final class PriceFilterType extends AbstractFilterType
{
public const MAXIMUM_PRICE_VALUE = 9999999999999999;
public function __construct(
private PriceNameResolverInterface $priceNameResolver,
private CurrencyContextInterface $currencyContext
) {
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add($this->priceNameResolver->resolveMinPriceName(), MoneyType::class, [
'label' => 'bitbag_sylius_elasticsearch_plugin.ui.min_price',
'required' => false,
'currency' => $this->currencyContext->getCurrencyCode(),
'constraints' => [
new Type([
'type' => 'numeric',
'message' => 'bitbag_sylius_elasticsearch_plugin.min_price_numeric',
]),
new PositiveOrZero([
'message' => 'bitbag_sylius_elasticsearch_plugin.min_price_positive_or_zero',
]),
new LessThan(self::MAXIMUM_PRICE_VALUE, options: [
'message' => 'bitbag_sylius_elasticsearch_plugin.price_value_too_large',
]),
],
])
->add($this->priceNameResolver->resolveMaxPriceName(), MoneyType::class, [
'label' => 'bitbag_sylius_elasticsearch_plugin.ui.max_price',
'required' => false,
'currency' => $this->currencyContext->getCurrencyCode(),
'constraints' => [
new Type([
'type' => 'numeric',
'message' => 'bitbag_sylius_elasticsearch_plugin.max_price_numeric',
]),
new PositiveOrZero([
'message' => 'bitbag_sylius_elasticsearch_plugin.max_price_positive_or_zero',
]),
new LessThan(self::MAXIMUM_PRICE_VALUE, options: [
'message' => 'bitbag_sylius_elasticsearch_plugin.price_value_too_large',
]),
],
])
->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
if (null !== $event->getData()) {
$data = [];
foreach ($event->getData() as $key => $item) {
$data[$key] = trim($item);
}
$event->setData($data);
}
})
;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/SearchType.php | src/Form/Type/SearchType.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use BitBag\SyliusElasticsearchPlugin\Facet\AutoDiscoverRegistryInterface;
use BitBag\SyliusElasticsearchPlugin\Form\EventSubscriber\AddFacetsEventSubscriber;
use BitBag\SyliusElasticsearchPlugin\Form\Resolver\ProductsFilterFacetResolverInterface;
use BitBag\SyliusElasticsearchPlugin\Model\Search;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
final class SearchType extends AbstractType
{
public function __construct(
private AutoDiscoverRegistryInterface $autoDiscoverRegistry,
private ProductsFilterFacetResolverInterface $facetsResolver
) {
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('query', TextType::class, [
'label' => false,
'required' => false,
'attr' => [
'placeholder' => 'bitbag_sylius_elasticsearch_plugin.ui.search_box.query.placeholder',
'class' => 'prompt app-quick-add-code-input',
],
])
->setMethod('GET')
;
$builder->addEventSubscriber(new AddFacetsEventSubscriber(
$this->autoDiscoverRegistry,
$this->facetsResolver
));
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Search::class,
'csrf_protection' => false,
]);
}
public function getBlockPrefix(): string
{
return 'bitbag_elasticsearch_search';
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/ProductAttributesFilterType.php | src/Form/Type/ProductAttributesFilterType.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use BitBag\SyliusElasticsearchPlugin\Context\ProductAttributesContextInterface;
use BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper\ProductAttributesMapperInterface;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
/** @deprecated */
final class ProductAttributesFilterType extends AbstractFilterType
{
public function __construct(
private ProductAttributesContextInterface $productAttributesContext,
private ConcatedNameResolverInterface $attributeNameResolver,
private ProductAttributesMapperInterface $productAttributesMapper,
private array $excludedAttributes
) {
}
public function buildForm(FormBuilderInterface $builder, array $attributes): void
{
/** @var array $options */
$options = $this->productAttributesContext->getAttributes();
foreach ($options as $productAttribute) {
if (in_array($productAttribute->getCode(), $this->excludedAttributes, true)) {
continue;
}
$name = $this->attributeNameResolver->resolvePropertyName($productAttribute->getCode());
$choices = $this->productAttributesMapper->mapToChoices($productAttribute);
$choices = array_unique($choices);
$builder->add($name, ChoiceType::class, [
'label' => $productAttribute->getName(),
'required' => false,
'multiple' => true,
'expanded' => true,
'choices' => $choices,
]);
}
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/ProductOptionsFilterType.php | src/Form/Type/ProductOptionsFilterType.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type;
use BitBag\SyliusElasticsearchPlugin\Context\ProductOptionsContextInterface;
use BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper\ProductOptionsMapperInterface;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
/** @deprecated */
final class ProductOptionsFilterType extends AbstractFilterType
{
public function __construct(
private ProductOptionsContextInterface $productOptionsContext,
private ConcatedNameResolverInterface $optionNameResolver,
private ProductOptionsMapperInterface $productOptionsMapper
) {
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var array $options */
$options = $this->productOptionsContext->getOptions();
foreach ($options as $productOption) {
$name = $this->optionNameResolver->resolvePropertyName($productOption->getCode());
$choices = $this->productOptionsMapper->mapToChoices($productOption);
$choices = array_unique($choices);
$builder->add($name, ChoiceType::class, [
'label' => $productOption->getName(),
'required' => false,
'multiple' => true,
'expanded' => true,
'choices' => $choices,
]);
}
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/ChoiceMapper/ProductAttributesMapperInterface.php | src/Form/Type/ChoiceMapper/ProductAttributesMapperInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper;
use Sylius\Component\Product\Model\ProductAttributeInterface;
interface ProductAttributesMapperInterface
{
public function mapToChoices(ProductAttributeInterface $productAttribute): array;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/ChoiceMapper/ProductOptionsMapper.php | src/Form/Type/ChoiceMapper/ProductOptionsMapper.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper;
use BitBag\SyliusElasticsearchPlugin\Formatter\StringFormatterInterface;
use Sylius\Component\Product\Model\ProductOptionInterface;
use Sylius\Component\Product\Model\ProductOptionValueInterface;
final class ProductOptionsMapper implements ProductOptionsMapperInterface
{
public function __construct(
private StringFormatterInterface $stringFormatter
) {
}
public function mapToChoices(ProductOptionInterface $productOption): array
{
$productOptionValues = $productOption->getValues()->toArray();
$choices = [];
array_walk(
$productOptionValues,
function (ProductOptionValueInterface $productOptionValue) use (&$choices): void {
/** @var string $value */
$value = $productOptionValue->getValue();
$choices[$value] = $this->stringFormatter->formatToLowercaseWithoutSpaces($value);
}
);
return $choices;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/ChoiceMapper/ProductOptionsMapperInterface.php | src/Form/Type/ChoiceMapper/ProductOptionsMapperInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper;
use Sylius\Component\Product\Model\ProductOptionInterface;
interface ProductOptionsMapperInterface
{
public function mapToChoices(ProductOptionInterface $productOption): array;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/ChoiceMapper/ProductAttributesMapper.php | src/Form/Type/ChoiceMapper/ProductAttributesMapper.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper;
use BitBag\SyliusElasticsearchPlugin\Context\TaxonContextInterface;
use BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper\AttributesMapper\AttributesMapperCollectorInterface;
use BitBag\SyliusElasticsearchPlugin\Formatter\StringFormatterInterface;
use BitBag\SyliusElasticsearchPlugin\Repository\ProductAttributeValueRepositoryInterface;
use Sylius\Component\Attribute\AttributeType\SelectAttributeType;
use Sylius\Component\Core\Model\Taxon;
use Sylius\Component\Locale\Context\LocaleContextInterface;
use Sylius\Component\Product\Model\ProductAttributeInterface;
final class ProductAttributesMapper implements ProductAttributesMapperInterface
{
public function __construct(
private ProductAttributeValueRepositoryInterface $productAttributeValueRepository,
private LocaleContextInterface $localeContext,
private StringFormatterInterface $stringFormatter,
private TaxonContextInterface $taxonContext,
/** @var $attributeMapper AttributesMapperCollectorInterface[] */
private iterable $attributeMapper
) {
}
public function mapToChoices(ProductAttributeInterface $productAttribute): array
{
$configuration = $productAttribute->getConfiguration();
if (isset($configuration['choices']) && is_array($configuration['choices'])) {
$choices = [];
foreach ($configuration['choices'] as $singleValue => $val) {
$label = $configuration['choices'][$singleValue][$this->localeContext->getLocaleCode()];
$singleValue = SelectAttributeType::TYPE === $productAttribute->getType() ? $label : $singleValue;
$choice = $this->stringFormatter->formatToLowercaseWithoutSpaces($singleValue);
$choices[$label] = $choice;
}
return $choices;
}
/** @var Taxon $taxon */
$taxon = $this->taxonContext->getTaxon();
$attributeValues = $this->productAttributeValueRepository->getUniqueAttributeValues($productAttribute, $taxon);
foreach ($this->attributeMapper as $mapper) {
if ($mapper->supports($productAttribute->getType())) {
return $mapper->map($attributeValues);
}
}
$choices = [];
array_walk($attributeValues, function ($productAttributeValue) use (&$choices, $productAttribute): void {
$value = $productAttributeValue['value'];
$configuration = $productAttribute->getConfiguration();
if (is_array($value)
&& isset($configuration['choices'])
&& is_array($configuration['choices'])
) {
foreach ($value as $singleValue) {
$choice = $this->stringFormatter->formatToLowercaseWithoutSpaces($singleValue);
$label = $configuration['choices'][$singleValue][$this->localeContext->getLocaleCode()];
$choices[$label] = $choice;
}
} else {
$choice = is_string($value) ? $this->stringFormatter->formatToLowercaseWithoutSpaces($value) : $value;
$choice = is_bool($value) ? var_export($value, true) : $choice;
$choices[$value] = $choice;
}
});
unset($attributeValues);
return $choices;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/ChoiceMapper/AttributesMapper/AttributesMapperCollectorInterface.php | src/Form/Type/ChoiceMapper/AttributesMapper/AttributesMapperCollectorInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper\AttributesMapper;
interface AttributesMapperCollectorInterface
{
public function supports(string $type): bool;
public function map(array $attributeValues): array;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/ChoiceMapper/AttributesMapper/AttributesTypePercentMapper.php | src/Form/Type/ChoiceMapper/AttributesMapper/AttributesTypePercentMapper.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper\AttributesMapper;
class AttributesTypePercentMapper implements AttributesMapperCollectorInterface
{
private const ATTRIBUTES_TYPE = 'percent';
public function supports(string $type): bool
{
return self::ATTRIBUTES_TYPE === $type;
}
public function map(array $attributeValues): array
{
$choices = [];
foreach ($attributeValues as $productAttributeValue) {
$value = $productAttributeValue['value'];
$choice = $value * 100;
$choices[$choice] = $value;
}
return $choices;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/ChoiceMapper/AttributesMapper/AttributesTypeDateMapper.php | src/Form/Type/ChoiceMapper/AttributesMapper/AttributesTypeDateMapper.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper\AttributesMapper;
final class AttributesTypeDateMapper implements AttributesMapperCollectorInterface
{
private const ATTRIBUTES_TYPE = 'date';
private const CHOICE_DATE_FORMAT = 'd-m-Y H:i';
private const VALUE_DATE_FORMAT = 'Y-m-d H:i:s.sss';
public function supports(string $type): bool
{
return self::ATTRIBUTES_TYPE === $type;
}
public function map(array $attributeValues): array
{
$choices = [];
foreach ($attributeValues as $productAttributeValue) {
$choice = $productAttributeValue['value']->format(self::CHOICE_DATE_FORMAT);
$value = $productAttributeValue['value']->format(self::VALUE_DATE_FORMAT);
$choices[$choice] = $value;
}
return $choices;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Type/ChoiceMapper/AttributesMapper/AttributesTypeDateTimeMapper.php | src/Form/Type/ChoiceMapper/AttributesMapper/AttributesTypeDateTimeMapper.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Type\ChoiceMapper\AttributesMapper;
class AttributesTypeDateTimeMapper implements AttributesMapperCollectorInterface
{
private const ATTRIBUTES_TYPE = 'datetime';
public function supports(string $type): bool
{
return self::ATTRIBUTES_TYPE === $type;
}
public function map(array $attributeValues): array
{
$choices = [];
foreach ($attributeValues as $productAttributeValue) {
$choice = $productAttributeValue['value']->format('d-m-Y H:i');
$value = $productAttributeValue['value']->format('Y-m-d H:i:s.sss');
$choices[$choice] = $value;
}
return $choices;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/EventSubscriber/AddFacetsEventSubscriber.php | src/Form/EventSubscriber/AddFacetsEventSubscriber.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\EventSubscriber;
use BitBag\SyliusElasticsearchPlugin\Facet\AutoDiscoverRegistryInterface;
use BitBag\SyliusElasticsearchPlugin\Form\Resolver\ProductsFilterFacetResolverInterface;
use BitBag\SyliusElasticsearchPlugin\Form\Type\SearchFacetsType;
use FOS\ElasticaBundle\Paginator\FantaPaginatorAdapter;
use Pagerfanta\Adapter\AdapterInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
final class AddFacetsEventSubscriber implements EventSubscriberInterface
{
public function __construct(
private AutoDiscoverRegistryInterface $autoDiscoverRegistry,
private ProductsFilterFacetResolverInterface $facetsResolver,
private string $namePropertyPrefix = ''
) {
}
public static function getSubscribedEvents(): array
{
return [
FormEvents::PRE_SUBMIT => 'addFacets',
];
}
public function addFacets(FormEvent $event): void
{
$this->autoDiscoverRegistry->autoRegister();
$adapter = $this->facetsResolver->resolveFacets($event, $this->namePropertyPrefix)->getAdapter();
$this->modifyForm($event->getForm(), $adapter);
}
private function modifyForm(FormInterface $form, AdapterInterface $adapter): void
{
if (!$adapter instanceof FantaPaginatorAdapter) {
return;
}
$form
->add('facets', SearchFacetsType::class, [
'facets' => $adapter->getAggregations(),
'label' => false,
'required' => false,
])
;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Resolver/FacetsResolver.php | src/Form/Resolver/FacetsResolver.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Resolver;
use BitBag\SyliusElasticsearchPlugin\Facet\RegistryInterface;
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\FormQueryBuilder\SiteWideFacetsQueryBuilderInterface;
use FOS\ElasticaBundle\Finder\PaginatedFinderInterface;
use Pagerfanta\Pagerfanta;
use Symfony\Component\Form\FormEvent;
final class FacetsResolver implements ProductsFilterFacetResolverInterface
{
public function __construct(
private SiteWideFacetsQueryBuilderInterface $queryBuilder,
private RegistryInterface $facetRegistry,
private PaginatedFinderInterface $finder
) {
}
public function resolveFacets(FormEvent $event, string $namePropertyPrefix): Pagerfanta
{
$query = $this->queryBuilder->getQuery($event);
foreach ($this->facetRegistry->getFacets() as $facetId => $facet) {
$query->addAggregation($facet->getAggregation()->setName((string) $facetId));
}
$query->setSize(0);
return $this->finder->findPaginated($query);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Resolver/ProductsFilterFacetResolverInterface.php | src/Form/Resolver/ProductsFilterFacetResolverInterface.php | <?php
/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Resolver;
use Pagerfanta\Pagerfanta;
use Symfony\Component\Form\FormEvent;
interface ProductsFilterFacetResolverInterface
{
public function resolveFacets(FormEvent $event, string $namePropertyPrefix): Pagerfanta;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Form/Resolver/ProductsFilterFacetResolver.php | src/Form/Resolver/ProductsFilterFacetResolver.php | <?php
/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Form\Resolver;
use BitBag\SyliusElasticsearchPlugin\Facet\RegistryInterface;
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\FormQueryBuilder\TaxonFacetsQueryBuilderInterface;
use FOS\ElasticaBundle\Finder\PaginatedFinderInterface;
use Pagerfanta\Pagerfanta;
use Symfony\Component\Form\FormEvent;
final class ProductsFilterFacetResolver implements ProductsFilterFacetResolverInterface
{
public function __construct(
private TaxonFacetsQueryBuilderInterface $queryBuilder,
private RegistryInterface $facetRegistry,
private PaginatedFinderInterface $finder
) {
}
public function resolveFacets(FormEvent $event, string $namePropertyPrefix): Pagerfanta
{
$query = $this->queryBuilder->getQuery($event, $namePropertyPrefix);
foreach ($this->facetRegistry->getFacets() as $facetId => $facet) {
$query->addAggregation($facet->getAggregation()->setName((string) $facetId));
}
$query->setSize(0);
return $this->finder->findPaginated($query);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/CompilerPass/AuthenticationManagerPolyfillPass.php | src/CompilerPass/AuthenticationManagerPolyfillPass.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\CompilerPass;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
final class AuthenticationManagerPolyfillPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if (
false === $container->has('security.authentication_manager')
&&
true === $container->has('security.authentication.manager')
) {
$container->setAlias('security.authentication_manager', 'security.authentication.manager');
}
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/DependencyInjection/BitBagSyliusElasticsearchExtension.php | src/DependencyInjection/BitBagSyliusElasticsearchExtension.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
final class BitBagSyliusElasticsearchExtension extends Extension implements PrependExtensionInterface
{
public function load(array $config, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../config'));
$loader->load('services.xml');
}
public function prepend(ContainerBuilder $container): void
{
$this->prependApiPlatformMapping($container);
}
private function prependApiPlatformMapping(ContainerBuilder $container): void
{
$container->prependExtensionConfig('api_platform', [
'mapping' => [
'paths' => [
$this->getPath($container, '/config/api_platform/'),
],
],
]);
}
private function getPath(ContainerBuilder $container, string $path): string
{
/** @var array<string, array<string, string>> $metadata */
$metadata = $container->getParameter('kernel.bundles_metadata');
return $metadata['BitBagSyliusElasticsearchPlugin']['path'] . $path;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Transformer/Product/ChannelPricingTransformer.php | src/Transformer/Product/ChannelPricingTransformer.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Transformer\Product;
use RuntimeException;
use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface;
use Sylius\Component\Channel\Context\ChannelContextInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Locale\Context\LocaleContextInterface;
use Sylius\Component\Product\Resolver\ProductVariantResolverInterface;
use Webmozart\Assert\Assert;
final class ChannelPricingTransformer implements TransformerInterface
{
public function __construct(
private ChannelContextInterface $channelContext,
private LocaleContextInterface $localeContext,
private ProductVariantResolverInterface $productVariantResolver,
private MoneyFormatterInterface $moneyFormatter
) {
}
public function transform(ProductInterface $product): ?string
{
/** @var ChannelInterface $channel */
$channel = $this->channelContext->getChannel();
if (null === $channelBaseCurrency = $channel->getBaseCurrency()) {
throw new RuntimeException('No channel currency configured');
}
/** @var ProductVariantInterface|null $productVariant */
$productVariant = $this->productVariantResolver->getVariant($product);
if (null === $productVariant) {
return null;
}
$productVariantPricing = $productVariant->getChannelPricingForChannel($channel);
if (null === $productVariantPricing) {
return null;
}
Assert::integer($productVariantPricing->getPrice());
Assert::string($channelBaseCurrency->getCode());
return $this->moneyFormatter->format(
$productVariantPricing->getPrice(),
$channelBaseCurrency->getCode(),
$this->localeContext->getLocaleCode()
);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Transformer/Product/TransformerInterface.php | src/Transformer/Product/TransformerInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Transformer\Product;
use Sylius\Component\Core\Model\ProductInterface;
interface TransformerInterface
{
public function transform(ProductInterface $product): ?string;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Transformer/Product/ImageTransformer.php | src/Transformer/Product/ImageTransformer.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Transformer\Product;
use Liip\ImagineBundle\Service\FilterService;
use Sylius\Component\Core\Model\ImageInterface;
use Sylius\Component\Core\Model\ProductInterface;
final class ImageTransformer implements TransformerInterface
{
private const SYLIUS_THUMBNAIL_TYPE = 'main';
private const SYLIUS_THUMBNAIL_FILTER = 'sylius_shop_product_thumbnail';
public function __construct(
private FilterService $imagineFilter,
private string $imagesPath = '/media/image/'
) {
}
public function transform(ProductInterface $product): ?string
{
$productThumbnails = $product->getImagesByType(self::SYLIUS_THUMBNAIL_TYPE);
if ($productThumbnails->isEmpty()) {
return null;
}
/** @var ImageInterface $productImage */
$productImage = $productThumbnails->first();
/** @var string $path */
$path = $productImage->getPath();
if ($this->canImageBeFiltered($path)) {
return $this->imagineFilter->getUrlOfFilteredImage($path, self::SYLIUS_THUMBNAIL_FILTER);
}
return $this->imagesPath . $productImage->getPath();
}
private function canImageBeFiltered(string $imagePath): bool
{
return !str_ends_with($imagePath, 'svg');
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Transformer/Product/SlugTransformer.php | src/Transformer/Product/SlugTransformer.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Transformer\Product;
use Sylius\Component\Core\Model\ProductInterface;
use Symfony\Component\Routing\RouterInterface;
final class SlugTransformer implements TransformerInterface
{
public function __construct(
private RouterInterface $router
) {
}
public function transform(ProductInterface $product): ?string
{
if (null === $product->getSlug()) {
return null;
}
return $this->router->generate('sylius_shop_product_show', ['slug' => $product->getSlug()]);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyNameResolver/SearchPropertyNameResolverRegistryInterface.php | src/PropertyNameResolver/SearchPropertyNameResolverRegistryInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
interface SearchPropertyNameResolverRegistryInterface
{
public function addPropertyNameResolver(ConcatedNameResolverInterface $propertyNameResolver): void;
/**
* @return ConcatedNameResolverInterface[]
*/
public function getPropertyNameResolvers(): array;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyNameResolver/PriceNameResolverInterface.php | src/PropertyNameResolver/PriceNameResolverInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
interface PriceNameResolverInterface
{
public function resolveMinPriceName(): string;
public function resolveMaxPriceName(): string;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyNameResolver/ConcatedNameResolverInterface.php | src/PropertyNameResolver/ConcatedNameResolverInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
interface ConcatedNameResolverInterface
{
public function resolvePropertyName(string $suffix): string;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyNameResolver/ConcatedNameResolver.php | src/PropertyNameResolver/ConcatedNameResolver.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
final class ConcatedNameResolver implements ConcatedNameResolverInterface
{
public function __construct(
private string $propertyPrefix
) {
}
public function resolvePropertyName(string $suffix): string
{
return strtolower($this->propertyPrefix . '_' . $suffix);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyNameResolver/SearchPropertyNameResolverRegistry.php | src/PropertyNameResolver/SearchPropertyNameResolverRegistry.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
final class SearchPropertyNameResolverRegistry implements SearchPropertyNameResolverRegistryInterface
{
/** @var ConcatedNameResolverInterface[] */
private array $propertyNameResolvers = [];
public function addPropertyNameResolver(ConcatedNameResolverInterface $propertyNameResolver): void
{
$this->propertyNameResolvers[] = $propertyNameResolver;
}
/**
* @return ConcatedNameResolverInterface[]
*/
public function getPropertyNameResolvers(): array
{
return $this->propertyNameResolvers;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyNameResolver/PriceNameResolver.php | src/PropertyNameResolver/PriceNameResolver.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyNameResolver;
final class PriceNameResolver implements PriceNameResolverInterface
{
public function __construct(
private string $pricePropertyPrefix
) {
}
public function resolveMinPriceName(): string
{
return 'min_' . $this->pricePropertyPrefix;
}
public function resolveMaxPriceName(): string
{
return 'max_' . $this->pricePropertyPrefix;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Context/ProductProductAttributesContext.php | src/Context/ProductProductAttributesContext.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
use BitBag\SyliusElasticsearchPlugin\Finder\ProductAttributesFinderInterface;
final class ProductProductAttributesContext implements ProductAttributesContextInterface
{
public function __construct(
private TaxonContextInterface $taxonContext,
private ProductAttributesFinderInterface $attributesFinder
) {
}
public function getAttributes(): ?array
{
$taxon = $this->taxonContext->getTaxon();
return $this->attributesFinder->findByTaxon($taxon);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Context/ProductOptionsContextInterface.php | src/Context/ProductOptionsContextInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
interface ProductOptionsContextInterface
{
public function getOptions(): ?array;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Context/ProductOptionsContext.php | src/Context/ProductOptionsContext.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
use BitBag\SyliusElasticsearchPlugin\Finder\ProductOptionsFinderInterface;
final class ProductOptionsContext implements ProductOptionsContextInterface
{
public function __construct(
private TaxonContextInterface $taxonContext,
private ProductOptionsFinderInterface $optionsFinder
) {
}
public function getOptions(): ?array
{
$taxon = $this->taxonContext->getTaxon();
return $this->optionsFinder->findByTaxon($taxon);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Context/TaxonContext.php | src/Context/TaxonContext.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
use BitBag\SyliusElasticsearchPlugin\Exception\TaxonNotFoundException;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Locale\Context\LocaleContextInterface;
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
final class TaxonContext implements TaxonContextInterface
{
public function __construct(
private RequestStack $requestStack,
private TaxonRepositoryInterface $taxonRepository,
private LocaleContextInterface $localeContext
) {
}
public function getTaxon(): TaxonInterface
{
/** @var Request $request */
$request = $this->requestStack->getCurrentRequest();
$slug = $request->get('slug');
$localeCode = $this->localeContext->getLocaleCode();
/** @var TaxonInterface|null $taxon */
$taxon = $this->taxonRepository->findOneBySlug($slug, $localeCode);
if (null === $slug || null === $taxon) {
throw new TaxonNotFoundException();
}
return $taxon;
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Context/ProductAttributesContextInterface.php | src/Context/ProductAttributesContextInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
interface ProductAttributesContextInterface
{
public function getAttributes(): ?array;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Context/TaxonContextInterface.php | src/Context/TaxonContextInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
use Sylius\Component\Core\Model\TaxonInterface;
interface TaxonContextInterface
{
public function getTaxon(): TaxonInterface;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/Context/ProductAttributesContext.php | src/Context/ProductAttributesContext.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\Context;
use BitBag\SyliusElasticsearchPlugin\Finder\ProductAttributesFinderInterface;
final class ProductAttributesContext implements ProductAttributesContextInterface
{
public function __construct(
private TaxonContextInterface $taxonContext,
private ProductAttributesFinderInterface $attributesFinder
) {
}
public function getAttributes(): ?array
{
$taxon = $this->taxonContext->getTaxon();
return $this->attributesFinder->findByTaxon($taxon);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/ProductCreatedAtPropertyBuilder.php | src/PropertyBuilder/ProductCreatedAtPropertyBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use Elastica\Document;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Sylius\Component\Core\Model\ProductInterface;
use Webmozart\Assert\Assert;
final class ProductCreatedAtPropertyBuilder extends AbstractBuilder
{
public function __construct(
private string $createdAtProperty
) {
}
public function consumeEvent(PostTransformEvent $event): void
{
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
Assert::notNull($product->getCreatedAt());
$createdAt = (int) $product->getCreatedAt()->format('U');
$document->set($this->createdAtProperty, $createdAt);
}
);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/AttributeBuilder.php | src/PropertyBuilder/AttributeBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\Formatter\StringFormatterInterface;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use Elastica\Document;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use function sprintf;
use Sylius\Component\Attribute\AttributeType\DateAttributeType;
use Sylius\Component\Attribute\AttributeType\DatetimeAttributeType;
use Sylius\Component\Attribute\AttributeType\SelectAttributeType;
use Sylius\Component\Attribute\Model\AttributeInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Product\Model\ProductAttributeValue;
final class AttributeBuilder extends AbstractBuilder
{
public const DEFAULT_DATE_TIME_FORMAT = 'Y-m-d H:i:s';
public const DEFAULT_DATE_FORMAT = 'Y-m-d';
public function __construct(
private ConcatedNameResolverInterface $attributeNameResolver,
private StringFormatterInterface $stringFormatter
) {
}
public function consumeEvent(PostTransformEvent $event): void
{
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
$this->resolveProductAttributes($product, $document);
}
);
}
private function resolveProductAttributes(ProductInterface $product, Document $document): void
{
/** @var ProductAttributeValue $productAttribute */
foreach ($product->getAttributes() as $productAttribute) {
$attribute = $productAttribute->getAttribute();
if (null === $attribute) {
continue;
}
$this->processAttribute($attribute, $productAttribute, $document);
}
}
private function resolveProductAttribute(
array $attributeConfiguration,
mixed $attributeValue,
ProductAttributeValue $productAttribute
): array {
/** @var AttributeInterface $attribute */
$attribute = $productAttribute->getAttribute();
if (SelectAttributeType::TYPE === $attribute->getType()) {
$choices = $attributeConfiguration['choices'];
if (is_array($attributeValue)) {
foreach ($attributeValue as $i => $item) {
$attributeValue[$i] = $choices[$item][$productAttribute->getLocaleCode()] ?? $item;
}
} else {
$attributeValue = $choices[$attributeValue][$productAttribute->getLocaleCode()] ?? $attributeValue;
}
}
$attributes = [];
if (is_array($attributeValue)) {
foreach ($attributeValue as $singleElement) {
$attributes[] = $this->stringFormatter->formatToLowercaseWithoutSpaces((string) $singleElement);
}
} else {
switch (true) {
case is_string($attributeValue):
$attributes[] = $this->stringFormatter->formatToLowercaseWithoutSpaces($attributeValue);
break;
case $attributeValue instanceof \DateTime:
$attributeFormat = $attribute->getConfiguration()['format'] ?? null;
$defaultFormat = DateAttributeType::TYPE === $attribute->getStorageType() ?
self::DEFAULT_DATE_FORMAT :
self::DEFAULT_DATE_TIME_FORMAT
;
$attributes[] = $attributeValue->format($attributeFormat ?? $defaultFormat);
break;
default:
$attributes[] = $attributeValue;
}
}
return $attributes;
}
private function processAttribute(
AttributeInterface $attribute,
ProductAttributeValue $productAttribute,
Document $document
): void {
/** @var string $attributeCode */
$attributeCode = $attribute->getCode();
$attributeConfiguration = $attribute->getConfiguration();
$value = $productAttribute->getValue();
$documentKey = $this->attributeNameResolver->resolvePropertyName($attributeCode);
$code = sprintf('%s_%s', $documentKey, $productAttribute->getLocaleCode());
$values = $this->resolveProductAttribute(
$attributeConfiguration,
$value,
$productAttribute
);
$values = in_array($attribute->getStorageType(), [DateAttributeType::TYPE, DatetimeAttributeType::TYPE], true) ?
($values[0] ?? $values) :
$values
;
$document->set($code, $values);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/SoldUnitsPropertyBuilder.php | src/PropertyBuilder/SoldUnitsPropertyBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\Repository\OrderItemRepositoryInterface;
use Elastica\Document;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
final class SoldUnitsPropertyBuilder extends AbstractBuilder
{
public function __construct(
private OrderItemRepositoryInterface $orderItemRepository,
private string $soldUnitsProperty
) {
}
public function consumeEvent(PostTransformEvent $event): void
{
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
$soldUnits = 0;
/** @var ProductVariantInterface $productVariant */
foreach ($product->getVariants() as $productVariant) {
$soldUnits += $this->orderItemRepository->countByVariant($productVariant);
}
$document->set($this->soldUnitsProperty, $soldUnits);
}
);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/PropertyBuilderInterface.php | src/PropertyBuilder/PropertyBuilderInterface.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
interface PropertyBuilderInterface extends EventSubscriberInterface
{
public function consumeEvent(PostTransformEvent $event): void;
public function buildProperty(
PostTransformEvent $event,
string $class,
callable $callback
): void;
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/ProductTaxonsBuilder.php | src/PropertyBuilder/ProductTaxonsBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\Mapper\ProductTaxonsMapperInterface;
use Elastica\Document;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Sylius\Component\Core\Model\ProductInterface;
final class ProductTaxonsBuilder extends AbstractBuilder
{
public function __construct(
private ProductTaxonsMapperInterface $productTaxonsMapper,
private string $taxonsProperty
) {
}
public function consumeEvent(PostTransformEvent $event): void
{
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
$taxons = $this->productTaxonsMapper->mapToUniqueCodes($product);
$document->set($this->taxonsProperty, $taxons);
}
);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/AbstractBuilder.php | src/PropertyBuilder/AbstractBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Sylius\Component\Resource\Model\ToggleableInterface;
abstract class AbstractBuilder implements PropertyBuilderInterface
{
public function buildProperty(
PostTransformEvent $event,
string $supportedModelClass,
callable $callback
): void {
$model = $event->getObject();
if (!$model instanceof $supportedModelClass || ($model instanceof ToggleableInterface && !$model->isEnabled())) {
return;
}
$document = $event->getDocument();
$callback($model, $document);
}
public static function getSubscribedEvents(): array
{
return [
PostTransformEvent::class => 'consumeEvent',
];
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/ChannelsBuilder.php | src/PropertyBuilder/ChannelsBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use Elastica\Document;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Sylius\Component\Core\Model\ProductInterface;
final class ChannelsBuilder extends AbstractBuilder
{
public function __construct(
private string $channelsProperty
) {
}
public function consumeEvent(PostTransformEvent $event): void
{
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
$channels = [];
foreach ($product->getChannels() as $channel) {
$channels[] = $channel->getCode();
}
$document->set($this->channelsProperty, $channels);
}
);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/AttributeTaxonsBuilder.php | src/PropertyBuilder/AttributeTaxonsBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\Repository\TaxonRepositoryInterface;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Sylius\Component\Attribute\Model\AttributeInterface;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Product\Model\ProductAttributeInterface;
final class AttributeTaxonsBuilder extends AbstractBuilder
{
public function __construct(
private TaxonRepositoryInterface $taxonRepository,
private string $taxonsProperty,
private bool $includeAllDescendants,
private array $excludedAttributes = []
) {
}
public function consumeEvent(PostTransformEvent $event): void
{
$documentAttribute = $event->getObject();
if (!$documentAttribute instanceof AttributeInterface
|| !$documentAttribute instanceof ProductAttributeInterface
|| in_array($documentAttribute->getCode(), $this->excludedAttributes, true)
) {
return;
}
$taxons = $this->taxonRepository->getTaxonsByAttributeViaProduct($documentAttribute);
$taxonCodes = [];
/** @var TaxonInterface $taxon */
foreach ($taxons as $taxon) {
$taxonCodes[] = $taxon->getCode();
if (true === $this->includeAllDescendants) {
foreach ($taxon->getAncestors() as $ancestor) {
$taxonCodes[] = $ancestor->getCode();
}
}
}
$document = $event->getDocument();
$document->set($this->taxonsProperty, $taxonCodes);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/ProductShortDescriptionBuilder.php | src/PropertyBuilder/ProductShortDescriptionBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use Elastica\Document;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductTranslationInterface;
final class ProductShortDescriptionBuilder extends AbstractBuilder
{
public function __construct(
private ConcatedNameResolverInterface $productShortDescriptionNameResolver
) {
}
public function consumeEvent(PostTransformEvent $event): void
{
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
/** @var ProductTranslationInterface $productTranslation */
foreach ($product->getTranslations() as $productTranslation) {
/** @var string $locale */
$locale = $productTranslation->getLocale();
$propertyName = $this->productShortDescriptionNameResolver->resolvePropertyName(
$locale
);
$document->set($propertyName, $productTranslation->getShortDescription());
}
}
);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/OptionTaxonsBuilder.php | src/PropertyBuilder/OptionTaxonsBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyBuilder\Mapper\ProductTaxonsMapperInterface;
use BitBag\SyliusElasticsearchPlugin\Repository\ProductVariantRepositoryInterface;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Sylius\Component\Product\Model\ProductOptionInterface;
use Sylius\Component\Product\Model\ProductOptionValueInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
final class OptionTaxonsBuilder extends AbstractBuilder
{
public function __construct(
private RepositoryInterface $productOptionValueRepository,
private ProductVariantRepositoryInterface $productVariantRepository,
private ProductTaxonsMapperInterface $productTaxonsMapper,
private string $taxonsProperty,
private array $excludedOptions = []
) {
}
public function consumeEvent(PostTransformEvent $event): void
{
$documentProductOption = $event->getObject();
if (!$documentProductOption instanceof ProductOptionInterface
|| in_array($documentProductOption->getCode(), $this->excludedOptions, true)
) {
return;
}
$document = $event->getDocument();
$optionValues = $this->productOptionValueRepository->findBy(['option' => $documentProductOption]);
$taxons = [];
/** @var ProductOptionValueInterface $optionValue */
foreach ($optionValues as $optionValue) {
$option = $optionValue->getOption();
$productVariants = $this->productVariantRepository->findByOptionValue($optionValue);
foreach ($productVariants as $productVariant) {
$product = $productVariant->getProduct();
if ($documentProductOption === $option && $product->isEnabled()) {
$taxons = array_merge($taxons, $this->productTaxonsMapper->mapToUniqueCodes($product));
}
}
}
$document->set($this->taxonsProperty, array_values(array_unique($taxons)));
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/ChannelPricingBuilder.php | src/PropertyBuilder/ChannelPricingBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use Elastica\Document;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
final class ChannelPricingBuilder extends AbstractBuilder
{
public function __construct(
private ConcatedNameResolverInterface $channelPricingNameResolver
) {
}
public function consumeEvent(PostTransformEvent $event): void
{
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
if (0 === $product->getVariants()->count()) {
return;
}
/** @var ProductVariantInterface $productVariant */
$productVariant = $product->getVariants()->first();
foreach ($productVariant->getChannelPricings() as $channelPricing) {
/** @var string $channelCode */
$channelCode = $channelPricing->getChannelCode();
$propertyName = $this->channelPricingNameResolver
->resolvePropertyName($channelCode);
$document->set($propertyName, $channelPricing->getPrice());
}
}
);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/OptionBuilder.php | src/PropertyBuilder/OptionBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\Formatter\StringFormatterInterface;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use Elastica\Document;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Product\Model\ProductOptionInterface;
final class OptionBuilder extends AbstractBuilder
{
public function __construct(
private ConcatedNameResolverInterface $optionNameResolver,
private StringFormatterInterface $stringFormatter
) {
}
public function consumeEvent(PostTransformEvent $event): void
{
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
$this->resolveProductOptions($product, $document);
}
);
}
private function resolveProductOptions(ProductInterface $product, Document $document): void
{
foreach ($product->getVariants() as $productVariant) {
foreach ($productVariant->getOptionValues() as $productOptionValue) {
/** @var ProductOptionInterface $option */
$option = $productOptionValue->getOption();
/** @var string $optionCode */
$optionCode = $option->getCode();
/** @var string $value */
$value = $productOptionValue->getValue();
$index = $this->optionNameResolver->resolvePropertyName($optionCode);
$options = $document->has($index) ? $document->get($index) : [];
$value = $this->stringFormatter->formatToLowercaseWithoutSpaces($value);
$options[] = $value;
$document->set($index, array_values(array_unique($options)));
}
}
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/ProductTaxonPositionPropertyBuilder.php | src/PropertyBuilder/ProductTaxonPositionPropertyBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use Elastica\Document;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\TaxonInterface;
final class ProductTaxonPositionPropertyBuilder extends AbstractBuilder
{
public function __construct(
private ConcatedNameResolverInterface $taxonPositionNameResolver
) {
}
public function consumeEvent(PostTransformEvent $event): void
{
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
foreach ($product->getProductTaxons() as $productTaxon) {
/** @var TaxonInterface $taxon */
$taxon = $productTaxon->getTaxon();
/** @var string $code */
$code = $taxon->getCode();
$document->set(
$this->taxonPositionNameResolver->resolvePropertyName($code),
$productTaxon->getPosition()
);
}
}
);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/ProductDescriptionBuilder.php | src/PropertyBuilder/ProductDescriptionBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use Elastica\Document;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductTranslationInterface;
final class ProductDescriptionBuilder extends AbstractBuilder
{
public function __construct(
private ConcatedNameResolverInterface $productDescriptionNameResolver
) {
}
public function consumeEvent(PostTransformEvent $event): void
{
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
/** @var ProductTranslationInterface $productTranslation */
foreach ($product->getTranslations() as $productTranslation) {
/** @var string $locale */
$locale = $productTranslation->getLocale();
$propertyName = $this->productDescriptionNameResolver->resolvePropertyName(
$locale
);
$document->set($propertyName, $productTranslation->getDescription());
}
}
);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
BitBagCommerce/SyliusElasticsearchPlugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/blob/12afd251bd3a3f7cf280cbb43166a94e89eac291/src/PropertyBuilder/ProductNameBuilder.php | src/PropertyBuilder/ProductNameBuilder.php | <?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use Elastica\Document;
use FOS\ElasticaBundle\Event\PostTransformEvent;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductTranslationInterface;
final class ProductNameBuilder extends AbstractBuilder
{
public function __construct(
private ConcatedNameResolverInterface $productNameNameResolver
) {
}
public function consumeEvent(PostTransformEvent $event): void
{
$this->buildProperty(
$event,
ProductInterface::class,
function (ProductInterface $product, Document $document): void {
/** @var ProductTranslationInterface $productTranslation */
foreach ($product->getTranslations() as $productTranslation) {
/** @var string $locale */
$locale = $productTranslation->getLocale();
$propertyName = $this->productNameNameResolver
->resolvePropertyName($locale);
$document->set($propertyName, $productTranslation->getName());
}
}
);
}
}
| php | MIT | 12afd251bd3a3f7cf280cbb43166a94e89eac291 | 2026-01-05T05:15:43.159589Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.