Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Product/SearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,28 @@ public function renderFacets(ProductSearchContext $context, ProductSearchResult
return '';
}

$language = $this->module->getContext()->language;

$this->module->getContext()->smarty->assign(
[
'show_quantities' => Configuration::get('PS_LAYERED_SHOW_QTIES'),
// Provide the language to the template so theme overrides can read it (e.g. the
// Hummingbird slider uses {$language.is_rtl} for the slider direction). It must be
// an ARRAY, mirroring the global `language` the front controller assigns (via
// ObjectPresenter), because the template accesses it with Smarty array syntax
// ({$language.is_rtl}); passing the Language object would make that a fatal
// "Cannot use object of type Language as array". (#41846)
'language' => [
'id' => (int) $language->id,
'name' => $language->name,
'iso_code' => $language->iso_code,
'locale' => $language->locale,
'language_code' => $language->language_code,
'active' => $language->active,
'is_rtl' => $language->is_rtl,
'date_format_lite' => $language->date_format_lite,
'date_format_full' => $language->date_format_full,
],
'facets' => $facetsVar,
'js_enabled' => $this->module->isAjax(),
'displayedFacets' => $displayedFacets,
Expand Down
32 changes: 32 additions & 0 deletions tests/php/FacetedSearch/Product/SearchProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ protected function setUp()
{
$this->database = Mockery::mock(Db::class);
$this->context = Mockery::mock(Context::class);
$this->context->language = Mockery::mock(\Language::class);
$this->context->language->id = 1;
$this->context->language->name = 'English (English)';
$this->context->language->iso_code = 'en';
$this->context->language->locale = 'en-US';
$this->context->language->language_code = 'en-us';
$this->context->language->active = true;
$this->context->language->is_rtl = false;
$this->context->language->date_format_lite = 'Y-m-d';
$this->context->language->date_format_full = 'Y-m-d H:i:s';
$this->converter = Mockery::mock(Converter::class);
$this->serializer = Mockery::mock(URLSerializer::class);
$this->facetCollection = Mockery::mock(FacetCollection::class);
Expand Down Expand Up @@ -181,6 +191,17 @@ public function testRenderFacetsWithFacetsCollection()
->with(
[
'show_quantities' => true,
'language' => [
'id' => 1,
'name' => 'English (English)',
'iso_code' => 'en',
'locale' => 'en-US',
'language_code' => 'en-us',
'active' => true,
'is_rtl' => false,
'date_format_lite' => 'Y-m-d',
'date_format_full' => 'Y-m-d H:i:s',
],
'facets' => [
[
'filters' => [],
Expand Down Expand Up @@ -240,6 +261,17 @@ public function testRenderFacetsWithFacetsCollectionAndFilters()
->with(
[
'show_quantities' => true,
'language' => [
'id' => 1,
'name' => 'English (English)',
'iso_code' => 'en',
'locale' => 'en-US',
'language_code' => 'en-us',
'active' => true,
'is_rtl' => false,
'date_format_lite' => 'Y-m-d',
'date_format_full' => 'Y-m-d H:i:s',
],
'facets' => [
[
'displayed' => true,
Expand Down
Loading