We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Re: How can I search and display SKU in Dawn theme 2.0?

How can I search and display SKU in Dawn theme 2.0?

greenonions
New Member
6 0 0

I've been able to add SKU as part of the display by adding this in the predictive-search.liquid for Dawn 2.0

                    <p> {%- assign current_variant = product.selected_or_first_available_variant -%}
                    <span>SKU: {{ current_variant.sku }}</span> </p>

There are two additional modifications I need, 

1. Ability to search by SKU

2. After pressing enter on search, display SKU in the screen that appears from the 'Search'.

 

Please be specific about what code modifications are needed and where to include them.

Replies 4 (4)

PaulNewton
Shopify Partner
8031 687 1647

Try adding variants.sku as a search parameter to search form behaviors.

i.e. ?q=variants.sku%1234abcd 

The native shopify search for the online sales channel is very basic and introductory.

It isn't meant to meet increasingly specific demands. So it's all workarounds.

 


@greenonions wrote:

Please be specific about what code modifications are needed and where to include them.


That feature is a large advanced customization beyond the scope of the forums.

Keep requests small and specific such as displaying/hiding some property, or styling.

 

Broadly you either need to:

  • use an actual dedicated search app/service that facilitates searching by a specific property
  • heavily customize the search to fake being a sku lookup / parts lookup tool (research the forums) by only showing exact match results in liquid and or javascript
  • and or heavily customize the filter system to use skus for filtering a collection with all products; and the limitations that comes with.


If you need this customization explored and built then contact me by my email for services.
Contact info in forum signature.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.

 

Good Luck.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


AutoPartsAAA
Tourist
7 1 3

Ability to search by SKU in Dawn V14.0 I had to edit assets/predictive-search.js

Look for the Fetch request and update as follows:

 

 fetch(`${routes.predictive_search_url}?q=${encodeURIComponent(searchTerm)}&resources[type]=product&resources[options][unavailable_products]=hide&resources[options][fields]=title,variants.sku,product_type,variants.title&section_id=predictive-search`,
     { signal: this.abortController.signal }
    )
      .then((response) => {
        if (!response.ok) {
          var error = new Error(response.status);
          this.close();
          throw error;
        }

 




slemey
Tourist
6 0 0

Hi, your code works, but I was wondering if it is possible to add something extra so that people can search a specific part of the SKU.
Let's say the item number SKU is: 99.5685.52.
I would like customer to search for 5685. and not the whole number beginning with 99.***

You think this is possible? Thx in advance

PrestigePlaybox
Visitor
1 0 0

Thank you!