Changing advanced search results query - Magento 2












0















I've extended the default layered navigation in magento 2 so that filter parameters are added like so:



?free_from=304_303_302


Where option ids are separated by an underscore, in the above example the product list displays all products with one or more of the 3 options selected.



This allows users to add more that one filter in each filterable category.



My question is how do i extend the way the advanced search builds the advanced search results query, so that it matches the way the layered navigation applies filters.



Currently, when I select multiple options from the advanced search and select search, it adds the query parameters in the form of an array,



?free_from%5B%5D=303&free_from%5B%5D=304&free_from%5B%5D=302


I need to change this so that it matches the layered navigation query, can anyone help me on this?



I can see the action of the advanced form is returned from MagentoCatalogSearchBlockAdvancedForm getSearchPostUrl(), and that this then retrieved the url from MagentoFrameworkViewElementAbstractBlock getUrl($route = '', $params = ), which method should i override and how do i retrieve the params and define the structure of the query?



Any help on this would be greatly appreciated.










share|improve this question





























    0















    I've extended the default layered navigation in magento 2 so that filter parameters are added like so:



    ?free_from=304_303_302


    Where option ids are separated by an underscore, in the above example the product list displays all products with one or more of the 3 options selected.



    This allows users to add more that one filter in each filterable category.



    My question is how do i extend the way the advanced search builds the advanced search results query, so that it matches the way the layered navigation applies filters.



    Currently, when I select multiple options from the advanced search and select search, it adds the query parameters in the form of an array,



    ?free_from%5B%5D=303&free_from%5B%5D=304&free_from%5B%5D=302


    I need to change this so that it matches the layered navigation query, can anyone help me on this?



    I can see the action of the advanced form is returned from MagentoCatalogSearchBlockAdvancedForm getSearchPostUrl(), and that this then retrieved the url from MagentoFrameworkViewElementAbstractBlock getUrl($route = '', $params = ), which method should i override and how do i retrieve the params and define the structure of the query?



    Any help on this would be greatly appreciated.










    share|improve this question



























      0












      0








      0








      I've extended the default layered navigation in magento 2 so that filter parameters are added like so:



      ?free_from=304_303_302


      Where option ids are separated by an underscore, in the above example the product list displays all products with one or more of the 3 options selected.



      This allows users to add more that one filter in each filterable category.



      My question is how do i extend the way the advanced search builds the advanced search results query, so that it matches the way the layered navigation applies filters.



      Currently, when I select multiple options from the advanced search and select search, it adds the query parameters in the form of an array,



      ?free_from%5B%5D=303&free_from%5B%5D=304&free_from%5B%5D=302


      I need to change this so that it matches the layered navigation query, can anyone help me on this?



      I can see the action of the advanced form is returned from MagentoCatalogSearchBlockAdvancedForm getSearchPostUrl(), and that this then retrieved the url from MagentoFrameworkViewElementAbstractBlock getUrl($route = '', $params = ), which method should i override and how do i retrieve the params and define the structure of the query?



      Any help on this would be greatly appreciated.










      share|improve this question
















      I've extended the default layered navigation in magento 2 so that filter parameters are added like so:



      ?free_from=304_303_302


      Where option ids are separated by an underscore, in the above example the product list displays all products with one or more of the 3 options selected.



      This allows users to add more that one filter in each filterable category.



      My question is how do i extend the way the advanced search builds the advanced search results query, so that it matches the way the layered navigation applies filters.



      Currently, when I select multiple options from the advanced search and select search, it adds the query parameters in the form of an array,



      ?free_from%5B%5D=303&free_from%5B%5D=304&free_from%5B%5D=302


      I need to change this so that it matches the layered navigation query, can anyone help me on this?



      I can see the action of the advanced form is returned from MagentoCatalogSearchBlockAdvancedForm getSearchPostUrl(), and that this then retrieved the url from MagentoFrameworkViewElementAbstractBlock getUrl($route = '', $params = ), which method should i override and how do i retrieve the params and define the structure of the query?



      Any help on this would be greatly appreciated.







      magento2 attributes products layered-navigation advanced-search






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 2 '16 at 15:39









      Marius

      164k28312663




      164k28312663










      asked Jul 25 '16 at 16:34









      Sophie BaxterSophie Baxter

      185622




      185622






















          1 Answer
          1






          active

          oldest

          votes


















          0














          We studied such an option to allow multiple selection of filters while writing ElasticSuite.



          The override should be in :




          • MagentoCatalogSearchModelLayerFilterAttribute::_getItemsData() (URL Generation in which you should set value to the imploded value)


          • MagentoCatalogSearchModelLayerFilterAttribute::apply (explode the value of the filter).



          Then you need to fix the DI. Take cares it is located into the frontend area. You can read a full example here :



          https://github.com/Smile-SA/elasticsuite/blob/master/src/module-elasticsuite-catalog/etc/frontend/di.xml



          You may also encounter some SQL, SolR or ES problem to handle the array.



          We have renounced to it since we do not use option ids but labels and it was a nightmare to handle multivalued this way. You can see the result here (looks likes your problem). : http://demo.magento-elastic-suite.io/index.php/women/tops-women.html?style_general%5B0%5D=Tee&style_general%5B1%5D=Pullover.



          Hope it's help.






          share|improve this answer
























          • Hi, thanks for this, but i don't have an issue applying multiple filters, i've installed an extension and this works correctly, my question is how do i change the advanced search results query to match the format of the layered navigation query i.e. ?free_from=304_303_302

            – Sophie Baxter
            Jul 26 '16 at 11:07











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f127346%2fchanging-advanced-search-results-query-magento-2%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          We studied such an option to allow multiple selection of filters while writing ElasticSuite.



          The override should be in :




          • MagentoCatalogSearchModelLayerFilterAttribute::_getItemsData() (URL Generation in which you should set value to the imploded value)


          • MagentoCatalogSearchModelLayerFilterAttribute::apply (explode the value of the filter).



          Then you need to fix the DI. Take cares it is located into the frontend area. You can read a full example here :



          https://github.com/Smile-SA/elasticsuite/blob/master/src/module-elasticsuite-catalog/etc/frontend/di.xml



          You may also encounter some SQL, SolR or ES problem to handle the array.



          We have renounced to it since we do not use option ids but labels and it was a nightmare to handle multivalued this way. You can see the result here (looks likes your problem). : http://demo.magento-elastic-suite.io/index.php/women/tops-women.html?style_general%5B0%5D=Tee&style_general%5B1%5D=Pullover.



          Hope it's help.






          share|improve this answer
























          • Hi, thanks for this, but i don't have an issue applying multiple filters, i've installed an extension and this works correctly, my question is how do i change the advanced search results query to match the format of the layered navigation query i.e. ?free_from=304_303_302

            – Sophie Baxter
            Jul 26 '16 at 11:07
















          0














          We studied such an option to allow multiple selection of filters while writing ElasticSuite.



          The override should be in :




          • MagentoCatalogSearchModelLayerFilterAttribute::_getItemsData() (URL Generation in which you should set value to the imploded value)


          • MagentoCatalogSearchModelLayerFilterAttribute::apply (explode the value of the filter).



          Then you need to fix the DI. Take cares it is located into the frontend area. You can read a full example here :



          https://github.com/Smile-SA/elasticsuite/blob/master/src/module-elasticsuite-catalog/etc/frontend/di.xml



          You may also encounter some SQL, SolR or ES problem to handle the array.



          We have renounced to it since we do not use option ids but labels and it was a nightmare to handle multivalued this way. You can see the result here (looks likes your problem). : http://demo.magento-elastic-suite.io/index.php/women/tops-women.html?style_general%5B0%5D=Tee&style_general%5B1%5D=Pullover.



          Hope it's help.






          share|improve this answer
























          • Hi, thanks for this, but i don't have an issue applying multiple filters, i've installed an extension and this works correctly, my question is how do i change the advanced search results query to match the format of the layered navigation query i.e. ?free_from=304_303_302

            – Sophie Baxter
            Jul 26 '16 at 11:07














          0












          0








          0







          We studied such an option to allow multiple selection of filters while writing ElasticSuite.



          The override should be in :




          • MagentoCatalogSearchModelLayerFilterAttribute::_getItemsData() (URL Generation in which you should set value to the imploded value)


          • MagentoCatalogSearchModelLayerFilterAttribute::apply (explode the value of the filter).



          Then you need to fix the DI. Take cares it is located into the frontend area. You can read a full example here :



          https://github.com/Smile-SA/elasticsuite/blob/master/src/module-elasticsuite-catalog/etc/frontend/di.xml



          You may also encounter some SQL, SolR or ES problem to handle the array.



          We have renounced to it since we do not use option ids but labels and it was a nightmare to handle multivalued this way. You can see the result here (looks likes your problem). : http://demo.magento-elastic-suite.io/index.php/women/tops-women.html?style_general%5B0%5D=Tee&style_general%5B1%5D=Pullover.



          Hope it's help.






          share|improve this answer













          We studied such an option to allow multiple selection of filters while writing ElasticSuite.



          The override should be in :




          • MagentoCatalogSearchModelLayerFilterAttribute::_getItemsData() (URL Generation in which you should set value to the imploded value)


          • MagentoCatalogSearchModelLayerFilterAttribute::apply (explode the value of the filter).



          Then you need to fix the DI. Take cares it is located into the frontend area. You can read a full example here :



          https://github.com/Smile-SA/elasticsuite/blob/master/src/module-elasticsuite-catalog/etc/frontend/di.xml



          You may also encounter some SQL, SolR or ES problem to handle the array.



          We have renounced to it since we do not use option ids but labels and it was a nightmare to handle multivalued this way. You can see the result here (looks likes your problem). : http://demo.magento-elastic-suite.io/index.php/women/tops-women.html?style_general%5B0%5D=Tee&style_general%5B1%5D=Pullover.



          Hope it's help.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jul 25 '16 at 17:40









          Aurélien FOUCRETAurélien FOUCRET

          1766




          1766













          • Hi, thanks for this, but i don't have an issue applying multiple filters, i've installed an extension and this works correctly, my question is how do i change the advanced search results query to match the format of the layered navigation query i.e. ?free_from=304_303_302

            – Sophie Baxter
            Jul 26 '16 at 11:07



















          • Hi, thanks for this, but i don't have an issue applying multiple filters, i've installed an extension and this works correctly, my question is how do i change the advanced search results query to match the format of the layered navigation query i.e. ?free_from=304_303_302

            – Sophie Baxter
            Jul 26 '16 at 11:07

















          Hi, thanks for this, but i don't have an issue applying multiple filters, i've installed an extension and this works correctly, my question is how do i change the advanced search results query to match the format of the layered navigation query i.e. ?free_from=304_303_302

          – Sophie Baxter
          Jul 26 '16 at 11:07





          Hi, thanks for this, but i don't have an issue applying multiple filters, i've installed an extension and this works correctly, my question is how do i change the advanced search results query to match the format of the layered navigation query i.e. ?free_from=304_303_302

          – Sophie Baxter
          Jul 26 '16 at 11:07


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f127346%2fchanging-advanced-search-results-query-magento-2%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          An IMO inspired problem

          Management

          Has there ever been an instance of an active nuclear power plant within or near a war zone?