Skip to content

Commit 66b1897

Browse files
committed
Fixes #70. Created filters for catalog promotion update grid.
1 parent ab4d896 commit 66b1897

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

src/DependencyInjection/SetonoSyliusCatalogPromotionExtension.php

+29
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Setono\SyliusCatalogPromotionPlugin\Checker\PreQualification\Rule\RuleCheckerInterface;
88
use Setono\SyliusCatalogPromotionPlugin\Checker\Runtime\RuntimeCheckerInterface;
9+
use Setono\SyliusCatalogPromotionPlugin\Model\CatalogPromotionUpdate;
910
use Setono\SyliusCatalogPromotionPlugin\Workflow\CatalogPromotionUpdateWorkflow;
1011
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension;
1112
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
@@ -118,6 +119,34 @@ public function prepend(ContainerBuilder $container): void
118119
'sortable' => null,
119120
],
120121
],
122+
'filters' => [
123+
'state' => [
124+
'type' => 'select',
125+
'label' => 'sylius.ui.state',
126+
'form_options' => [
127+
'choices' => array_combine(
128+
array_map(static fn (string $state) => sprintf('setono_sylius_catalog_promotion.ui.%s', $state), CatalogPromotionUpdate::getStates()),
129+
CatalogPromotionUpdate::getStates(),
130+
),
131+
],
132+
],
133+
'triggeredBy' => [
134+
'type' => 'string',
135+
'label' => 'setono_sylius_catalog_promotion.ui.triggered_by',
136+
],
137+
'error' => [
138+
'type' => 'string',
139+
'label' => 'sylius.ui.error',
140+
],
141+
'createdAt' => [
142+
'type' => 'date',
143+
'label' => 'sylius.ui.created_at',
144+
'options' => [
145+
'field' => 'createdAt',
146+
'inclusive_from' => true,
147+
],
148+
],
149+
],
121150
'actions' => [
122151
'main' => [
123152
'back_to_catalog_promotions' => [

src/Model/CatalogPromotionUpdate.php

+13
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ public function setState(string $state): void
6262
$this->state = $state;
6363
}
6464

65+
/**
66+
* @return list<string>
67+
*/
68+
public static function getStates(): array
69+
{
70+
return [
71+
self::STATE_PENDING,
72+
self::STATE_PROCESSING,
73+
self::STATE_COMPLETED,
74+
self::STATE_FAILED,
75+
];
76+
}
77+
6578
public function getError(): ?string
6679
{
6780
return $this->error;

src/Resources/translations/messages.en.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ setono_sylius_catalog_promotion:
3939
catalog_promotion: Catalog promotion
4040
catalog_promotion_updates: Catalog promotion updates
4141
catalog_promotions: Catalog promotions
42+
completed: Completed
4243
edit_catalog_promotion: Edit catalog promotion
44+
failed: Failed
4345
list_of_updates: List of updates
4446
manage_catalog_promotions: Manage catalog promotions
4547
manually_discounted_products_excluded: Manually discounted products excluded
4648
new_catalog_promotion: Create new catalog promotion
4749
no_end_date: No end date
4850
no_error: No error
4951
no_start_date: No start date
52+
pending: Pending
53+
processing: Processing
5054
products_updated: Products updated
5155
products_updated_less_than_estimated: The number of products updated is less than the estimated number of products to update. This may be due to the fact that some products were filtered/edited/removed after the initial processing started.
5256
rules_explanation: If you don't add any rules, the catalog promotion will be applied to all products

0 commit comments

Comments
 (0)