Product Facet not shown when exactly 1 value is present - Spartacus - spartacus-storefront

Spartacus v 3.1
Problem
In SOLR response of PLP when there is a facet being returned with only 1 value and 1 count (e.g. Camera : Sony(1)). While this facet is appearing in the response , the facet is not being displayed in the facet component.
Is this a normal OOTB behavior of the product ?
If yes, Any means to override this behavior ?

Posting the answer here for Reference
https://github.com/SAP/spartacus/pull/6600
The (current) backend returns facets with values that do not contribute to the facet navigation much, as the number in the result list will not get affected when they got applied. A ticket has been created to optimise this behaviour in the backend.
As long as this is not in place, we manually filter the facet from the list; any facet that does not have a count < the total results will be dropped from the facets.
PR for this fix https://github.com/SAP/spartacus/pull/6600

Related

Algolia vue-instantsearch : disjunction between two distincts facets

Using algolia vue-instantsearch, i’m encountering a special case and i’m having an hard time finding a solution.
Refinement behaviors is that you get the results that matches all your refinement filters.
If i filter on a brand and a price, i’ll get the results that matches both the brand and the price.
I need to add some specific filters that work differently. I would like to be able to say “returns me the results that matches either refinementA, or refinementB, or refinementC.”
The reason is that those refinements are checking fields that are not present on all the products.
If i check a value for refinementA, i want to keep all the results that has no value for field corresponding to refinementA, but remove those that has a value for refinementA that does not match with the one i filtered one.
Im thinking about handling myself some inputs instead of ias-components, and modifying by hand each query that is send to algolia by checking the value of my own inputs when searchFunction is triggered (https://www.algolia.com/doc/api-reference/widgets/instantsearch/js/#widget-param-searchfunction).
I did not found yet how i can trigger a search from an non-vue-instantsearch input event, and i’m not sure how the above solution could affect the internal working of vue-instantsearch.
I’m looking for feedbacks about a more standard way of doing this, or for any advices !
I got the answer by exchanging with a vue-instantsearch maintainer.
vue-instantsearch does not provide any option to do it.
A workaround is to overwrite algoliasearch search method, that is used under the hood by vue-instant-search.
const client = algoliasearch('', '');
const originalSearch = client.search;
client.search = function search(queries) { ... }
More informations in this github issue : https://github.com/algolia/vue-instantsearch/issues/1102

getAllPrebidWinningBids() returns something but getAllWinningBids() is empty

I've been struggling with pbjs and DFP for several days now and my current problem is the one described in the title: when I type pbjs.getAllPrebidWinningBids() in the console, something is returned but nothing is displayed on my test page, and when I type pbjs.getAllWinningBids(), an empty array is returned and I don't get why.
A few more info :
This is a test page on our server with no other competition;
We use custom price buckets;
In DFP, I have 5 line items from 0.00€ to 2.00€ (so a 0.50€ increment) that matches the custom price buckets in the code;
The bids are "redirected" in the correct price buckets;
The code works and an ad is displayed when I set up a self-promotion
campaign in DFP with a prebid snippet as a creative, so I suppose
that something is wrong with the price buckets.
Would someone have an idea of what is blocking the selection of the bid and the rendering?
Thanks!
EDIT : I've come to realize that it was actually a normal behaviour since pbjs.getAllPrebidWinningBids() returns the bids that won the auction but haven't rendered on the page yet, while pbjs.getAllWinningBids() returns those that won but have also rendered.
So my question now is why the hell is no ad rendered at all?!
Here's my code (with a few dummy values), in case someone understand what's wrong: https://jsfiddle.net/8ewz9rgb/2/
Not answering the original thread question, instead your new issue why no ads are rendering. This is because you are calling GPT's googletag.disableInitialLoad. This will not render ads until googletag.refresh is called, which doesn't happen because it's in a 'pbjs' queue and you are not loading Prebid here, it is 404ing.

Sitecore REST API search By Navigation Category

I am working on building a REST API based connector to a marketplace which uses sitecore. I have found the documentation for using the search API command here:
https://sdn.sitecore.net/upload/sitecore6/65/sitecore_search_and_indexing_sc60-65-a4.pdf
I have been unable to figure out how to use it to search for content that is grouped into a navigation category, and was unsure if there was a good way to do this. I did not design the site, and the designers were contractors who are no longer working with us.
I would like to be able to find a list of items based on a specific navigation category that has been assigned to them. I have tried getting the children of the category ID itself, but that did not work. Here is a picture of the navigation category associated with a given object in case it adds clarification:
enter image description here
Is there an easy way to search for items like this?
Going with the assumption that you are on 7.2 or above, you just need to search for items that have the ID of the Navigation Categorization field (in your index as navigation_categorization) that are set to the ID of the item you wish to filter on. In your image, it would be the ID of "connectivity services" item.
var context = ContentSearchManager.GetIndex("master").CreateSearchContext();
var computedLanguage = Sitecore.Context.Language.CultureInfo.Name;
// get the iBuild items
var results = context.GetQueryable<SearchResultItem>()
.Where(i => i["navigation_categorization"].Contains([connectivity services ID])
&& i.Language == computedLanguage)
.GetResults()
.Hits.Select(x => x.Document.GetItem(
));

querying categorymembers with wikimedia and the size

I try to get the page sizes of all category members through the wikimedia api with only one request.(or less then 10).
I know I would get the sizes of pages by:
(1) Requesting every page separately and get the size
or
(2) A search query like this:
http://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=physics
The result is several pages with the size and word count property.
Now how can I get the size and word count for a category member with a query like this or with another trick ?
http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Physics
Any hints shared would be appreciated.
You can use a category query as a generator, using generator=categorymember and gcmtitle=Category:Physics. This will execute the query action for each and every page in that category:
api.php?action=query
&generator=categorymembers
&gcmtitle=Category:Lakes
&prop=info
In the docs you can see what properties can be used as generators: categories, links and templates. Also, more or less every list module can be used as a generator in the same fashion.
Note that parameter names are prefixed with a g when used for a generator, so that cmtitle in the example above becomes gcmtitle, to distinguish them from parameters to the query action (that is applied to every page returned by the generator), prop and inprop, parameters

Google custom search REST number of results (num field)

I'm trying to figure out how to force google custom search to give me back 20 results per page.
I've tried to send this REST request configuring my new Custom Search Engine to:
Standard edition: Free, ads are required on results pages.
https://www.googleapis.com/customsearch/v1?key=AIzaSyCgGuZie_Xo-hOECNXOTKp5Yk7deryqro8&cx=015864032944730029962:5ipe0q27hgy&q=test&alt=json&num=20
IT NOT WORKS!
but
https://www.googleapis.com/customsearch/v1?key=AIzaSyCgGuZie_Xo-hOECNXOTKp5Yk7deryqro8&cx=015864032944730029962:5ipe0q27hgy&q=test&alt=json&num=10
IT WORKS!
But reading documentation at
https://developers.google.com/custom-search/docs/xml_results#numsp
it says that:
Optional. The num parameter identifies the number of search results to return.
The default num value is 10, and the maximum value is 20. If you request more than 20 results, only 20 results will be returned.
Note: If the total number of search results is less than the requested number of results, all available search results will be returned.
Someone has experienced this problem?
PS: I've tried also to send that REST request configuring my new Custom Search Engine to:
Site Search: Starts at $100 per year, ads are optional on results pages.
But nothing has changed no way to obtain 20 results in a request/page
This documentation url has descriptions of each parameter. It also says num is restricted to integers between 1 and 10, inclusive.
https://developers.google.com/custom-search/v1/using_rest#query-params