Skip to content

Commit

Permalink
Merge pull request #3034 from plentymarkets/fix/category_facet_filter
Browse files Browse the repository at this point in the history
Fix/category facet filter
  • Loading branch information
Tim-M-S authored Oct 5, 2021
2 parents 06933b3 + 0195a9b commit 6791c59
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 12 deletions.
1 change: 1 addition & 0 deletions resources/lang/de/Widget.properties
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ availabilityFilterLabel = "Verfügbarkeitsfilter"
priceFilterLabel = "Preisfilter"
; Category filter
categoryFilterLabel = "Kategoriefilter"
categoryPlaceholderDescription = "Dieses Widget ist nur sichtbar, wenn die Einstellung 'Kategorien als Filteroptionen bei Suchergebnissen anzeigen' im plentyShop-Assistenten aktiv ist."
; Selected Filter
selectedFilterWidgetLabel = "Ausgewählte Filter"
; Manufacturer Filter
Expand Down
1 change: 1 addition & 0 deletions resources/lang/de/Wizard.properties
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ categoryDescriptionBoth = Beschreibung 1 und 2
categoryDescriptionBelow = Welche Kategoriebeschreibung möchtest du unter der Artikelliste anzeigen?
enableImageCarousel = Bilderkarussell in der Kategorieansicht aktivieren
showCarouselDots = Punkte-Navigation unten im Bilderkarussell anzeigen
showCategoryFilter = Kategorien als Filteroptionen bei Suchergebnissen anzeigen
showCarouselNav = Navigationspfeile zum Steuern des Bilderkarussells anzeigen
itemViewSettings = Einstellungen für die Artikelansicht
itemViewSettingsDescription = Bestellmerkmale in der Artikelansicht
Expand Down
3 changes: 2 additions & 1 deletion resources/lang/en/Widget.properties
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@ availabilityFilterLabel = "Availability filter"
priceFilterLabel = "Price filter"
; Category filter
categoryFilterLabel = "Category filter"
categoryPlaceholderDescription = "This widget is only visible if the setting 'Show categories as filter options for search results' in the plentyShop assistant is active."
; Selected Filter
selectedFilterWidgetLabel = "Selected filters"
; Manufacturer Filter
Expand Down Expand Up @@ -1015,4 +1016,4 @@ maxPreloadTooltip = "Number of images to be preloaded"
; LanguageDetection
languageDetectionLabel = "Language detection"
languageDetectionWidgetLabel = "Language detection"
languageDetectionRedirect = "Activate automatic redirect"
languageDetectionRedirect = "Activate automatic redirect"
1 change: 1 addition & 0 deletions resources/lang/en/Wizard.properties
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ categoryDescriptionBoth = Description 1 and 2
categoryDescriptionBelow = Which category description do you want to display below item lists?
enableImageCarousel = Show image carousel in the category view
showCarouselDots = Show dot navigation in the image carousel
showCategoryFilter = Show categories as filter options for search results
showCarouselNav = Show navigation arrows in the image carousel
itemViewSettings = Settings for the item view
itemViewSettingsDescription = Order characteristics in the item view
Expand Down
28 changes: 20 additions & 8 deletions resources/views/Widgets/Category/Filter/FilterBaseWidget.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,29 @@

{% set appearance = widget.settings.appearance.mobile | default("none") %}

{{ Twig.set("hasCategoryFilter", "ceresConfig.item.showCategoryFilter") }}
{{ Twig.set("className", "className") }}

{{ Twig.if("services.facet.facetDataExists(facets, #{allowedFacetTypes | json_encode}) or #{ isPreview | json_encode }") }}
<div class="widget widget-filter-base widget-{{ appearance }}{% if customClass | length > 0 %} {{ customClass }}{% endif %}{% if spacingMargin | length > 0 %} {{ spacingMargin }}{% endif %}"
{% if inlineMargin | length > 0 %} style="{{ inlineMargin }}"{% endif %}>

<item-filter-list
class="{{ "widget-filter-" ~ className }}"
:filter-list-bulk="true"
:facet-data="{{ Twig.print('facets | json_encode') }}"
:allowed-facets-types="{{ allowedFacetTypes | json_encode }}"
:padding-classes="{{ spacingPadding | json_encode }}"
:padding-inline-styles="{{ inlinePadding | json_encode }}">
</item-filter-list>
{{ Twig.if("className == 'category' and hasCategoryFilter == false") }}
<div class="widget-placeholder p-0">
<div>
<p class="title mb-0">{{ trans("Ceres::Widget.categoryFilterLabel") }}</p>
<p class="description mt-2 mb-2">{{ trans("Ceres::Widget.categoryPlaceholderDescription") }}</p>
</div>
</div>
{{ Twig.else() }}
<item-filter-list
class="{{ "widget-filter-" ~ className }}"
:filter-list-bulk="true"
:facet-data="{{ Twig.print('facets | json_encode') }}"
:allowed-facets-types="{{ allowedFacetTypes | json_encode }}"
:padding-classes="{{ spacingPadding | json_encode }}"
:padding-inline-styles="{{ inlinePadding | json_encode }}">
</item-filter-list>
{{ Twig.endif() }}
</div>
{{ Twig.endif() }}
2 changes: 1 addition & 1 deletion src/Config/CeresItemConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,6 @@ protected function load()
$this->showCategoryDescriptionTop = $this->getTextValue( 'item.show_category_description_top', 'description1' );
$this->showCategoryDescriptionBottom = $this->getTextValue( 'item.show_category_description_bottom', 'none' );
$this->requireOrderProperties = $this->getBooleanValue( 'item.require_all_properties', false );

$this->showCategoryFilter = $this->getBooleanValue( 'item.show_category_filter', false );
}
}
7 changes: 5 additions & 2 deletions src/Widgets/Category/Filter/FilterBaseWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ protected function getPreviewData($widgetSettings)
/** @var FacetFaker $facetFaker */
$facetFaker = pluginApp(FacetFaker::class);
$facetResult = $facetFaker->fill([]);

return ['facets' => $facetResult];

return [
'facets' => $facetResult,
'className' => $this->className
];
}
}
6 changes: 6 additions & 0 deletions src/Wizard/ShopWizard/Mapping/DisplayInfoMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class DisplayInfoMapping
"global" => false,
"optional" => true,
],
"displayInfo_showCategoryFilter"=> [
"field" => "item.show_category_filter",
"type" => "string",
"global" => false,
"optional" => true,
],
"displayInfo_showDescriptionTop" => [
"field" => "item.show_category_description_top",
"type" => "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ private function generateCategoryView(): array
"name" => "Wizard.showCarouselNav",
]
],
"displayInfo_showCategoryFilter" => [
"type" => "checkbox",
"defaultValue" => false,
"options" => [
"name" => "Wizard.showCategoryFilter",
]
],
]
];
}
Expand Down

0 comments on commit 6791c59

Please sign in to comment.