Skip to content

Commit

Permalink
Fix Smile-SA/elasticsuite-for-retailer#11 - Performances optiomizatio…
Browse files Browse the repository at this point in the history
…n (add configuration parameter to set the maximum number of stores to display)
  • Loading branch information
Maxime LECLERCQ committed Sep 3, 2018
1 parent 966e840 commit ff18142
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Block/Search.php
Expand Up @@ -210,7 +210,7 @@ protected function _prepareLayout()
private function getRetailerCollection()
{
$retailerCollection = $this->retailerCollectionFactory->create();
$retailerCollection->addAttributeToSelect('*');
$retailerCollection->addAttributeToSelect(['name', 'contact_mail', 'contact_phone', 'contact_mail']);
$retailerCollection->addFieldToFilter('is_active', (int) true);
$retailerCollection->addOrder('name', 'asc');

Expand Down
1 change: 1 addition & 0 deletions Model/RetailerAddress/Source/Country.php
Expand Up @@ -58,6 +58,7 @@ public function getAllOptions()
{
if ($this->_options === null) {
$this->_options = $this->countriesFactory->create()
->loadByStore()
->toOptionArray();
}

Expand Down
32 changes: 32 additions & 0 deletions etc/adminhtml/system.xml
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<!--
/**
* Smile_StoreLocator admin configuration UI fields.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future.
*
*
* @category Smile
* @package Smile\StoreLocator
* @author Maxime Leclercq <maxime.leclercq@smile.fr>
* @copyright 2018 Smile
* @license Open Software License ("OSL") v. 3.0
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>

<section id="smile_map" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">

<group id="map" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="provider_all_max_visible_shop" translate="label" type="text" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="100">
<label>Maximum number of visible stores</label>
<comment>Above this limit, the list of stores will be not display</comment>
</field>
</group>
</section>
</system>
</config>
5 changes: 5 additions & 0 deletions etc/config.xml
Expand Up @@ -17,6 +17,11 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<smile_map>
<map>
<provider_all_max_visible_shop>1000</provider_all_max_visible_shop>
</map>
</smile_map>
<store_locator>
<seo>
<base_url>stores</base_url>
Expand Down
3 changes: 3 additions & 0 deletions i18n/en_US.csv
Expand Up @@ -55,3 +55,6 @@ Longitude,Longitude
"Shop Search","Shop Search"
"View Shop Page","View Shop Page"
"Double-click on an opening hour range to delete it.","Double-click on an opening hour range to delete it."
"Narrow your search to see store details","Narrow your search to see store details"
"Maximum number of visible stores","Maximum number of visible stores"
"Above this limit, the list of stores will be not display","Above this limit, the list of stores will be not display"
3 changes: 3 additions & 0 deletions i18n/fr_FR.csv
Expand Up @@ -55,3 +55,6 @@ Longitude,Longitude
"Shop Search","Localiser un magasin"
"View Shop Page","Voir la page du magasin"
"Double-click on an opening hour range to delete it.","Double-cliquez sur une tranche horaire pour la supprimer."
"Narrow your search to see store details","Affinez votre recherche pour voir le détail des magasins"
"Maximum number of visible stores","Nombre maximum de magasins visible"
"Above this limit, the list of stores will be not display","Au-delà de cette limite, la liste des magasins ne sera pas affichée"
5 changes: 5 additions & 0 deletions view/frontend/web/css/source/_module.less
Expand Up @@ -317,6 +317,11 @@
background: #F0F0F0;
}
}

.max_stores_message {
margin: 0;
padding: 5px;
}
}

.shop-details {
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/web/js/model/store.js
Expand Up @@ -19,7 +19,7 @@ define([

initObservable: function () {
if (this.schedule) {
this.schedule = ko.observable(new Schedule(this.schedule));
this.schedule = ko.observable(this.schedule);
}

return this;
Expand Down
11 changes: 9 additions & 2 deletions view/frontend/web/template/retailer/search.html
Expand Up @@ -32,9 +32,16 @@
<p data-bind="text: $t(searchResultsLabel).replace('%s', $parent.countDisplayedMarkers.bind($parent))"></p>
<span data-bind="if: $parent.displayReset()"><a data-bind="{click: $parent.resetMap.bind($parent)}"><span data-bind="text: $t(viewAllLabel)"></span></a></span>
</div>
<ul data-bind="foreach: $parent.displayedMarkers">
<li data-bind="template: $parent.storeListTemplate" class="result-item"></li>
<!-- ko if: $parent.displayedMarkers().length < $parent.max_visible_shop -->
<ul data-bind="{foreach: $parent.displayedMarkers()}">
<li data-bind="{template: $parent.storeListTemplate}" class="result-item"></li>
</ul>
<!-- /ko -->
<!-- ko ifnot: $parent.displayedMarkers().length < $parent.max_visible_shop -->
<div class="max_stores_message">
<strong data-bind="text: $t('Narrow your search to see store details')"></strong>
</div>
<!-- /ko -->
</div>
</div>

Expand Down

0 comments on commit ff18142

Please sign in to comment.