Announcement

Collapse
No announcement yet.

Exclude Products from Miva's Native Search

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Exclude Products from Miva's Native Search

    Hi,

    I am migrating from Power Search and still in the testing process.

    How can I exclude certain products from the search results?

    In Power Search we were using the following in the Description field to accomplish that.
    <!-- miva_nodisplay //-->

    Thanks,
    Mike

    #2
    Following. I'm also in the process of trying to migrate from PowerSearch - there are several features (like that one,) and customizations that I'm finding difficult to replicate with Miva native search.
    Psydde Delicious
    Delicious Boutique & Corseterie
    Philadelphia, PA
    www.DeliciousBoutique.com
    www.DeliciousCorsets.com

    Comment


      #3
      Me too, me too! Gosh, we should try to compile a list of the PowerSearch features being used. I have a site that is pretty much run by PowerSearch functionality and it's enough to make my head explode trying to find all of the places it touches.
      Leslie Kirk
      Miva Certified Developer
      Miva Merchant Specialist since 1997
      Previously of Webs Your Way
      (aka Leslie Nord leslienord)

      Email me: [email protected]
      www.lesliekirk.com

      Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

      Comment


        #4
        If not using filtering

        Set a custom field (exclude_from_search) for products, and then run

        <mvt:if expr="l.settings:custom:exclude_from_search">
        <mvt:foreachcontinue/>
        </mvt:if>

        inside the loop.

        Filtering is tricker cause, if i remember correctly, its done via JS and you'd have to do something similar there (but likely having to remove the product from the actual array structure).

        oh, add
        <mvt:assign name="l.settings:custom:count_adjust" value="l.settings:custom:count_adjust + 1" />

        before the foreachcontinue and then use that to substract the 'total' count (forgot the variable name) that miva uses for page count and pagination..
        Bruce Golub
        Phosphor Media - "Your Success is our Business"

        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
        phosphormedia.com

        Comment


          #5
          Thanks Bruce, as always!

          Going to mess around with the custom field.

          I'm surprised there is nothing built-in to allow product exclusions because I feel like that was a huge feature in power search.

          Comment


            #6
            I can't find where I can edit the results. I have the item “search_results” assigned to my SRCH_TEST page. I wanted to tweak it slightly and add what Bruce suggested to the loop. I see the module “cmp-cssui-prodlist” listed but can't figure out where to edit.

            Coming from Power Search I was able to make edits like this in the module's interface under utilities.

            Comment


              #7
              You need to make sure the search_results item is assigned and then use the Search Results Layout template code.
              Bruce Golub
              Phosphor Media - "Your Success is our Business"

              Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
              phosphormedia.com

              Comment


                #8
                I also need to exclude some products from the search results. I've tried to make sense of Bruce's suggestion but can't seem to get that code placed to work correctly. Here is the standard search code I'm starting with:

                Code:
                <mvt:if expr="NOT ISNULL g.Search">
                     <mvt:if expr="l.settings:search_product_count GT 0">
                          <mvt:item name="search_results" />
                     </mvt:if>
                </mvt:if>
                Would somebody please rewrite the code to exlude products that have checkbox checked for custom field exlcude_from_search? If you write some code that works, you are smarter than ChatGPT...
                Matt E.
                www.harpkit.com

                Comment


                  #9
                  Hi Matt,

                  That section of code loads the Search Restults Layout section, which is a separate block of code on the SRCH page. If you post the code from that section, someone may be able to help you sort out where to add Bruce's code.

                  Comment


                    #10
                    Code:
                    <mvt:foreach iterator="product" array="search_results:products">
                    <mvt:item name="customfields" param="Read_Product_ID( l.settings:product:id, 'custom_field_code', l.settings:custom:custom_field_code)" />
                    <mvt:if expr="l.settings:custom:custom_field_code">
                         <mvt:foreachcontinue/>
                    </mvt:if>
                    
                    
                    ...
                    </mvt:foreach>
                    if you're really being tidy, you need to do something similar to the facets loop if you are using it.

                    You'll need to do something similar the JS code that runs the 'search suggestions' display (but i don't have that one memorized :) )

                    Beware though, i'd only use this if its one or two items not coming up cause this will throw off pagination counts.
                    Bruce Golub
                    Phosphor Media - "Your Success is our Business"

                    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                    phosphormedia.com

                    Comment


                      #11
                      Thank you, Leanne and Bruce, for pointing me in the right direction. I was able to make it work and exclude products from the search results. Unfortunately, the products still show up in the search preview. I tried tweaking the code for that to no avail.

                      Here's hoping Miva adds a simple way to exclude products from the search results (and search preview) in a future update.
                      Matt E.
                      www.harpkit.com

                      Comment


                        #12
                        Global Settings >> Search Settings | Menu Item Template

                        Wrap the entire template with


                        Code:
                        <mvt:item name="customfields" param="Read_Product_ID( l.settings:product:id, 'custom_field_code', l.settings:custom:custom_field_code)" />
                        <mvt:if expr="l.settings:custom:custom_field_code">
                        
                        ...rest of template
                        
                        </mvt:if>
                        Bruce Golub
                        Phosphor Media - "Your Success is our Business"

                        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                        phosphormedia.com

                        Comment


                          #13
                          I had tried that. Using that code, nothing is shown in the search preview.
                          Matt E.
                          www.harpkit.com

                          Comment


                            #14
                            can you post the actual code you used.
                            Bruce Golub
                            Phosphor Media - "Your Success is our Business"

                            Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                            phosphormedia.com

                            Comment


                              #15
                              Sure. Here is the original code found in Global Settings >> Search Settings | Menu Item Template

                              Code:
                              <div class="x-search-preview__list" data-search="&mvte:product:name;">
                              <div class="x-search-preview__line">
                              <figure class="x-search-preview__image">
                              <mvt:if expr="NOT ISNULL l.settings:product:imagetypes:main">
                              <img src="&mvte:product:imagetypes:main;" alt="&mvte:product:name;" loading="lazy" width="&mvte:searchfield:b_width;" height="&mvte:searchfield:b_height;">
                              </mvt:if>
                              </figure>
                              <div class="x-search-preview__item">
                              <span class="x-search-preview__item-name">&mvte:product:name;</span>
                              <hr class="c-keyline">
                              <span class="x-search-preview__item-price u-text-right">
                              <mvt:if expr="l.settings:product:base_price GT l.settings:product:price">
                              <span class="u-font-small">Was: <s>&mvt:product:formatted_base_price;</s><br></span>
                              </mvt:if>
                              <strong>&mvt:product:formatted_price;</strong>
                              </span>
                              </div>
                              </div>
                              </div>


                              And here is what I tried that did not work -

                              Code:
                              <mvt:item name="customfields" param="Read_Product_ID( l.settings:product:id, 'exclude_from_search', l.settings:custom:exclude_from_search)" />
                              <mvt:if expr="l.settings:custom:exclude_from_search">
                              
                              <div class="x-search-preview__list" data-search="&mvte:product:name;">
                              <div class="x-search-preview__line">
                              <figure class="x-search-preview__image">
                              <mvt:if expr="NOT ISNULL l.settings:product:imagetypes:main">
                              <img src="&mvte:product:imagetypes:main;" alt="&mvte:product:name;" loading="lazy" width="&mvte:searchfield:b_width;" height="&mvte:searchfield:b_height;">
                              </mvt:if>
                              </figure>
                              <div class="x-search-preview__item">
                              <span class="x-search-preview__item-name">&mvte:product:name;</span>
                              <hr class="c-keyline">
                              <span class="x-search-preview__item-price u-text-right">
                              <mvt:if expr="l.settings:product:base_price GT l.settings:product:price">
                              <span class="u-font-small">Was: <s>&mvt:product:formatted_base_price;</s><br></span>
                              </mvt:if>
                              <strong>&mvt:product:formatted_price;</strong>
                              </span>
                              </div>
                              </div>
                              </div>
                              
                              </mvt:if>
                              Matt E.
                              www.harpkit.com

                              Comment

                              Working...
                              X