Skip to content

Commit

Permalink
Search by partial zipcode is handle by map/geocoder provider - openst…
Browse files Browse the repository at this point in the history
…reetmap and google map does not have same result on same search - so add config on search placeholder to be able to correctly advice customer during search
  • Loading branch information
livca-smile committed Nov 16, 2023
1 parent 9816532 commit b1b3f98
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Block/Catalog/Product/Retailer/Availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Smile\Retailer\Api\Data\RetailerExtensionInterface;
use Smile\Retailer\Api\Data\RetailerInterface;
use Smile\Retailer\Model\ResourceModel\Retailer\CollectionFactory as RetailerCollectionFactory;
use Smile\RetailerOffer\Helper\Config as HelperConfig;

/**
* Block rendering availability in store for a given product.
Expand All @@ -40,6 +41,7 @@ public function __construct(
protected RetailerCollectionFactory $retailerCollectionFactory,
protected AddressFormatter $addressFormatter,
protected Region $region,
protected HelperConfig $helperConfig,
MapProviderInterface $mapProvider,
array $data = []
) {
Expand All @@ -61,6 +63,8 @@ public function getJsLayout()

$jsLayout['components']['catalog-product-retailer-availability']['productId'] = $this->getProduct()->getId();
$jsLayout['components']['catalog-product-retailer-availability']['storeOffers'] = $this->getStoreOffers();
$jsLayout['components']['catalog-product-retailer-availability']['searchPlaceholderText'] = $this
->helperConfig->getSearchPlaceholder();

return json_encode($jsLayout);
}
Expand Down
29 changes: 29 additions & 0 deletions Helper/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Smile\RetailerOffer\Helper;

use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Store\Model\ScopeInterface;

class Config extends AbstractHelper
{
public const SEARCH_PLACEHOLDER_XML_PATH = 'smile_retailersuite_retailer_base_settings/search/placeholder';

/**
* Get config by config path.
*/
public function getConfigByPath(string $path, string $scope = ScopeInterface::SCOPE_STORE): mixed
{
return $this->scopeConfig->getValue($path, $scope);
}

/**
* Get placeholder for search input of store_locator, default: City, Zipcode, Address, ...
*/
public function getSearchPlaceholder(): string
{
return (string) $this->getConfigByPath(self::SEARCH_PLACEHOLDER_XML_PATH) ?: 'City, Zipcode, Address ...';
}
}
9 changes: 9 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<resource>Magento_Backend::config_smile_retailersuite_retailer_base_settings</resource>

<group id="navigation_settings" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Main Settings</label>
<field id="navigation_mode" translate="label comment" type="select" sortOrder="200" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Navigation mode</label>
<comment>Drive mode : the customer will only see the catalog of the chosen retailer in Front Office. Retail mode : the customer will browse the Web catalog by default.</comment>
Expand All @@ -20,6 +21,14 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>
<!-- avoid nth dependency with Smile_StoreLocator -->
<group id="search" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Search Settings</label>
<field id="placeholder" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Shown placeholder to help user</label>
<comment>default: City, Zipcode, Address ...</comment>
</field>
</group>
</section>
</system>
</config>
3 changes: 3 additions & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<navigation_mode>0</navigation_mode>
<display_offers>1</display_offers>
</navigation_settings>
<search>
<placeholder>City, Zipcode, Address ...</placeholder>
</search>
</smile_retailersuite_retailer_base_settings>
</default>
</config>
1 change: 1 addition & 0 deletions i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ ID,ID
Search,Search
"Retailer Offers","Retailer Offers"
"Not Selected","Not Selected"
"City, Zipcode, Address ...","City, Zipcode, Address ..."
1 change: 1 addition & 0 deletions i18n/fr_FR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ ID,ID
Search,Search
"Retailer Offers","Offres Magasin"
"Not Selected","Non Sélectionné"
"City, Zipcode, Address ...","Ville, code postal, addresse ..."
1 change: 0 additions & 1 deletion view/frontend/layout/catalog_product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<item name="component" xsi:type="string">Smile_RetailerOffer/js/retailer/product-availability</item>
<item name="storeOffersListTemplate" xsi:type="string">Smile_RetailerOffer/retailer/product/store-list</item>
<item name="searchTitleText" xsi:type="string" translate="true">Find a store :</item>
<item name="searchPlaceholderText" xsi:type="string" translate="true">City, Zipcode, Department, ...</item>
<item name="searchButtonText" xsi:type="string" translate="true">Search</item>
<item name="radius" xsi:type="string">25000</item>
</item>
Expand Down

0 comments on commit b1b3f98

Please sign in to comment.