Answers.Body: <p>So I found that using the paginate tag would return all entries regardless of the keyword. I was able to get it to work by using the below results code. <em>(pagination still worked without the use of the pagination tag)</em></p>
  
  <pre><code>{% set query = craft.request.getParam('q') %}
  
  {% set tag = craft.tags.title(query).first() %}
  
  {% set products = craft.commerce.products.search(query).limit(48) %}
  {% if products|length %}
  {% for product in products %}
     &lt;div class="item"&gt;
        &lt;div class="item-wrapper"&gt;
          &lt;figure class="he-3 cyan"&gt;
            &lt;img src="{{ product.presentationSlides.first().getUrl('mediaDetail') }}" alt="{{ product.name }}"&gt;
            &lt;div class="hover-icons"&gt;
              &lt;div class="hover-icons-wrapper"&gt;
                &lt;a href="{{ product.presentationSlides.first().getUrl('mediaLightbox') }}" class="magnific hidden-xs-down"&gt;
                  &lt;i class="nc-icon-outline ui-1_zoom"&gt;&lt;/i&gt;
                &lt;/a&gt;
                &lt;a href="{{ product.url }}"&gt;
                  &lt;i class="nc-icon-outline ui-2_link-71"&gt;&lt;/i&gt;
                &lt;/a&gt;
                &lt;a href="#" class="hidden-xs-down"&gt;
                  &lt;i class="nc-icon-outline ui-2_favourite-28"&gt;&lt;/i&gt;
                &lt;/a&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/figure&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  {% endfor %}
  {% else %}
     &lt;p&gt;No Results&lt;/p&gt;  
  {% endif %}
  
  /*pagination code */
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-25T21:44:57.797Z
Answers.LastActivityDate: 2016-12-25T21:44:57.797Z
Answers.UserDisplayName: EDub
Answers.Body: <p>This should work (set the limit to whatever you want/need):</p>
  
  <pre><code>{% set tag = craft.tags.title(tagTitle).first() %}    
  
  {% paginate craft.commerce.products.relatedTo(tag).limit(10) as pageInfo, products %}
  
      {% for product in products %}
  
          {{ product.title }} etc
  
      {% endfor %}
  
      {% if pageInfo.prevUrl %}&lt;a href="{{ pageInfo.prevUrl }}"&gt;Previous Page&lt;/a&gt;{% endif %}
      {% if pageInfo.nextUrl %}&lt;a href="{{ pageInfo.nextUrl }}"&gt;Next Page&lt;/a&gt;{% endif %}
  </code></pre>
  
  <p>For more on the pagination side of things, see: <a href="https://craftcms.com/docs/templating/paginate" rel="nofollow noreferrer">https://craftcms.com/docs/templating/paginate</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-22T02:57:22.883Z
Answers.LastActivityDate: 2016-12-22T02:57:22.883Z
Answers.UserDisplayName: Jeremy Daalder
Body: <p>this is my first Craft CMS &amp; Commerce build and I need some help with searching products by a tag field.</p>
  
  <p>I have a tag field ("designTag") for each product and I would like to have a search bar that will only query the tag field for a specific product type ("designMedia") and return those products with matching or similar tag titles and also account for pagination. I can't seem to get it to work. Any help would be appreciated.
  <br><br></p>
  
  <p><strong>SEARCH FORM CODE:</strong><br></p>
  
  <pre><code>&lt;form action="{{ url('design/keywords') }}"&gt;
      &lt;label&gt;Search By Keywords&lt;/label&gt;
      &lt;div class="append-icon"&gt;
          &lt;input type="search" name="q" class="form-control input-lg" placeholder="Enter Keyword..."&gt;
          &lt;button class="btn" type="submit"&gt;&lt;i class="nc-icon-outline ui-1_zoom"&gt;&lt;/i&gt;&lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>RESULTS CODE:</strong><br></p>
  
  <pre><code>{% set tagTitle = craft.request.getParam('q') %}
  {% set tag = craft.tags.title(tagTitle) %}    
  {% set product = craft.commerce.products.search(query).order('score') %}
  
  {% if product|length %}
  
  {% paginate craft.commerce.products.type('designMedia').limit(48) as mediaProducts %}
  
  {% for product in mediaProducts %}    
         &lt;div class="item"&gt;
            &lt;div class="item-wrapper"&gt;
              &lt;figure class="he-3 cyan"&gt;
                &lt;img src="{{ product.presentationSlides.first().getUrl('mediaDetail') }}" alt="{{ product.name }}"&gt;
                &lt;div class="hover-icons"&gt;
                  &lt;div class="hover-icons-wrapper"&gt;
                    &lt;a href="{{ product.presentationSlides.first().getUrl('mediaLightbox') }}" class="magnific hidden-xs-down"&gt;
                      &lt;i class="nc-icon-outline ui-1_zoom"&gt;&lt;/i&gt;
                    &lt;/a&gt;
                    &lt;a href="{{ product.url }}"&gt;
                      &lt;i class="nc-icon-outline ui-2_link-71"&gt;&lt;/i&gt;
                    &lt;/a&gt;
                    &lt;a href="#" class="hidden-xs-down"&gt;
                      &lt;i class="nc-icon-outline ui-2_favourite-28"&gt;&lt;/i&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
              &lt;/figure&gt;
            &lt;/div&gt;
          &lt;/div&gt;
  {% endfor %}
  {% else %}
      &lt;p&gt;No Results&lt;/p&gt;  
  {% endif %}
  
  /*pagination code */
  {% endpaginate %}
  </code></pre>
  
Tags: <templating><plugin-craftcommerce><search>
Title: Search Commerce Products by Tags
ThreadText: # Search Commerce Products by Tags
  
  (Asked by: username_0 on 2016-12-21)
  
  this is my first Craft CMS & Commerce build and I need some help with searching products by a tag field.
  
  I have a tag field ("designTag") for each product and I would like to have a search bar that will only query the tag field for a specific product type ("designMedia") and return those products with matching or similar tag titles and also account for pagination. I can't seem to get it to work. Any help would be appreciated.
  
  **SEARCH FORM CODE:**
  
  ```
  <form action="{{ url('design/keywords') }}">
      <label>Search By Keywords</label>
      <div class="append-icon">
          <input type="search" name="q" class="form-control input-lg" placeholder="Enter Keyword...">
          <button class="btn" type="submit"><i class="nc-icon-outline ui-1_zoom"></i></button>
      </div>
  </form>
  
  ```
  
  **RESULTS CODE:**
  
  ```
  {% set tagTitle = craft.request.getParam('q') %}
  {% set tag = craft.tags.title(tagTitle) %}    
  {% set product = craft.commerce.products.search(query).order('score') %}
  
  {% if product|length %}
  
  {% paginate craft.commerce.products.type('designMedia').limit(48) as mediaProducts %}
  
  {% for product in mediaProducts %}    
         <div class="item">
            <div class="item-wrapper">
              <figure class="he-3 cyan">
                <img src="{{ product.presentationSlides.first().getUrl('mediaDetail') }}" alt="{{ product.name }}">
                <div class="hover-icons">
                  <div class="hover-icons-wrapper">
                    <a href="{{ product.presentationSlides.first().getUrl('mediaLightbox') }}" class="magnific hidden-xs-down">
                      <i class="nc-icon-outline ui-1_zoom"></i>
                    </a>
                    <a href="{{ product.url }}">
                      <i class="nc-icon-outline ui-2_link-71"></i>
                    </a>
                    <a href="#" class="hidden-xs-down">
                      <i class="nc-icon-outline ui-2_favourite-28"></i>
                    </a>
                  </div>
                </div>
              </figure>
            </div>
          </div>
  {% endfor %}
  {% else %}
      <p>No Results</p>  
  {% endif %}
  
  /*pagination code */
  {% endpaginate %}
  
  ```
  
  **Tags:** templating, plugin-craftcommerce, search
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2016-12-25. Score: 1 | Accepted answer
  
  So I found that using the paginate tag would return all entries regardless of the keyword. I was able to get it to work by using the below results code. *(pagination still worked without the use of the pagination tag)*
  
  ```
  {% set query = craft.request.getParam('q') %}
  
  {% set tag = craft.tags.title(query).first() %}
  
  {% set products = craft.commerce.products.search(query).limit(48) %}
  {% if products|length %}
  {% for product in products %}
     <div class="item">
        <div class="item-wrapper">
          <figure class="he-3 cyan">
            <img src="{{ product.presentationSlides.first().getUrl('mediaDetail') }}" alt="{{ product.name }}">
            <div class="hover-icons">
              <div class="hover-icons-wrapper">
                <a href="{{ product.presentationSlides.first().getUrl('mediaLightbox') }}" class="magnific hidden-xs-down">
                  <i class="nc-icon-outline ui-1_zoom"></i>
                </a>
                <a href="{{ product.url }}">
                  <i class="nc-icon-outline ui-2_link-71"></i>
                </a>
                <a href="#" class="hidden-xs-down">
                  <i class="nc-icon-outline ui-2_favourite-28"></i>
                </a>
              </div>
            </div>
          </figure>
        </div>
      </div>
  {% endfor %}
  {% else %}
     <p>No Results</p>  
  {% endif %}
  
  /*pagination code */
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2016-12-22. Score: 2
  
  This should work (set the limit to whatever you want/need):
  
  ```
  {% set tag = craft.tags.title(tagTitle).first() %}    
  
  {% paginate craft.commerce.products.relatedTo(tag).limit(10) as pageInfo, products %}
  
      {% for product in products %}
  
          {{ product.title }} etc
  
      {% endfor %}
  
      {% if pageInfo.prevUrl %}<a href="{{ pageInfo.prevUrl }}">Previous Page</a>{% endif %}
      {% if pageInfo.nextUrl %}<a href="{{ pageInfo.nextUrl }}">Next Page</a>{% endif %}
  
  ```
  
  For more on the pagination side of things, see: <https://craftcms.com/docs/templating/paginate>
  
  
  ---
  
  