diff --git a/docs/add_custom_sorts.md b/docs/add_custom_sorts.md new file mode 100644 index 00000000..a51e9b00 --- /dev/null +++ b/docs/add_custom_sorts.md @@ -0,0 +1 @@ +@TODO diff --git a/docs/add_custom_values.md b/docs/add_custom_values.md new file mode 100644 index 00000000..8905fab2 --- /dev/null +++ b/docs/add_custom_values.md @@ -0,0 +1,58 @@ +# Add custom values to your indexed entity + +## Add custom value for a product + +In our example we will add the `short_description` product field to the indexed content. + +First, declares your services : + +```yaml + App\Search\EventListener\AppendProductMappingSubscriber: + autoconfigure: true + + App\Search\Automapper\DecorateProductMapperConfiguration: + autowire: true + decorates: MonsieurBiz\SyliusSearchPlugin\AutoMapper\ProductMapperConfiguration + arguments: + - '@.inner' +``` + +```php + 'onMappingProvider', + ]; + } + + public function onMappingProvider(MappingProviderEvent $event): void + { + // We work on products, ignore the rest + if ('monsieurbiz_product' !== $event->getIndexCode()) { + return; + } + + $mapping = $event->getMapping(); + if (null === $mapping || !$mapping->offsetExists('mappings')) { + return; + } + + $mappings['properties']['short_description'] = [ + 'type' => 'text', + ]; + + $mapping->offsetSet('mappings', $mappings); + } +} +``` diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..4431312d --- /dev/null +++ b/docs/index.md @@ -0,0 +1,10 @@ +# SyliusSearchPlugin + +@TODO Description + +## Menu + +- [Add custom sorts](./add_custom_sorts.md) +- [Add custom values](./add_custom_values.md) +- [Index custom entities](./index_custom_entities.md) +- [Nested fields limit](./nested_fields_limit.md) diff --git a/docs/index_custom_entities.md b/docs/index_custom_entities.md new file mode 100644 index 00000000..a51e9b00 --- /dev/null +++ b/docs/index_custom_entities.md @@ -0,0 +1 @@ +@TODO diff --git a/docs/nested_fields_limit.md b/docs/nested_fields_limit.md new file mode 100644 index 00000000..6cb185d8 --- /dev/null +++ b/docs/nested_fields_limit.md @@ -0,0 +1,37 @@ +@TODO + +```php + 'onMappingProvider', + ]; + } + + public function onMappingProvider(MappingProviderEvent $event): void + { + if ('monsieurbiz_product' !== $event->getIndexCode()) { + return; + } + + $mapping = $event->getMapping(); + if (null === $mapping || !$mapping->offsetExists('mappings')) { + return; + } + + $settings = $mapping->offsetGet('settings') ?? []; + $mapping->offsetSet('settings', array_merge($settings, ['mapping.nested_fields.limit' => 100])); // Increase the limit of nested fields + } +} +``` diff --git a/src/Resources/public/js/monsieurbiz-search.2f3a873a.js b/src/Resources/public/js/monsieurbiz-search.2f3a873a.js new file mode 100644 index 00000000..5c7c3eeb --- /dev/null +++ b/src/Resources/public/js/monsieurbiz-search.2f3a873a.js @@ -0,0 +1 @@ +!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/bundles/monsieurbizsyliussearchplugin/",n(n.s="ng4s")}({"2mad":function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},ng4s:function(e,t,n){(function(e){function t(e,t){for(var n=0;n=i){var e=new XMLHttpRequest;e.onload=function(){200===this.status&&(c.innerHTML=this.responseText,c.style.display="block")},e.open("POST",t),e.setRequestHeader("X-Requested-With","XMLHttpRequest"),e.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),e.send(new URLSearchParams({query:n}).toString())}}),u)}));var l=c.closest(r);l.addEventListener("focusout",(function(e){null!==e.relatedTarget&&l.contains(e.relatedTarget)||(l.querySelector(o).style.display="none")})),c.addEventListener("focus",(function(e){""!==e.currentTarget.value&&(l.querySelector(o).style.display="block")}))}},n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}(),document.addEventListener("DOMContentLoaded",(function(){new MonsieurBizInstantSearch(monsieurbizSearchPlugin.instantUrl,monsieurbizSearchPlugin.searchInputSelector,monsieurbizSearchPlugin.resultClosestSelector,monsieurbizSearchPlugin.resultFindSelector,monsieurbizSearchPlugin.keyUpTimeOut,monsieurbizSearchPlugin.minQueryLength)}))}).call(this,n("2mad"))}}); \ No newline at end of file