Magento 2.4 collection filtering no longer working - strange paging issue - magento2

I'll start by saying that this worked correctly prior to Magento 2.4.
using $collection->addAttributeToFilter("sku",'21V12') does seem to filter the products, but it does so very strangely. if i have 20 products in a category and i use that filter, there are 2 different scenarios
The results are correct and it shows 1 of 1
The results show "We can't find products matching the selection."
the difference is that if the sku i'm filtering on is on page 1, then i get the first results, but if the sku is on a different page, i get the "We can't find products matching the selection."
If I add the page to the url, I get the result (adding p=2 or p=3 for example)
Any idea why that is? I've tried this in multiple points in the code to no avail.
That filtering on sku is a simple example, but lets say we want to do a more involved filter like
$collection->addAttributeToFilter("special_name",'some_custom_text')
and that gives 20 results, sometimes there are none on page 1 and 3 on page 2, etc.
Anyway, it seems to just be hiding items in the display and not actually giving the results we are looking for.
I've tested this on a baseline 2.4.2 install with the Luma theme.
To verify, the easiest way, add this at line 147 in vendor/magento/module-catalog/Model/Layer.php
$collection->addAttributeToFilter("sku",'21V12');
Substitute a sku you have on page 2 of a category page. you should get the "We can't find products matching the selection." page, but if you add ?p=2 (or whatever page your item is on normally) you'll get that product as a result.

Related

Displaying a 'Top Result' with Algolia?

I want to search 3 different indices at once, breaking out their results into 3 separate sections.
Above these 3 sections though, I want to display a 4th section with a single result row, and this section will be titled "Best Result".
It should take the best result of the 3 indices that most perfectly matches.
Does anyone know how I can achieve this? Thanks!
By design, when the ranking of each index is properly set (both attributeToIndex, and customRanking settings filled), the Algolia engine returns the most relevant et popular results for each new search request. First the one without typos and with perfect matches, then the others...
Which mean that if you want to display all the top results on a single page, you only need to take the N first result of each index.
Then it's just a matter of display. Like on the following websites, you can imagine to display those results into multiple columns:
http://telly.com/
Prototype built using the TED API
Feel free to look at tips about the best way to display result hits in multiple columns using Algolia and Bootstrap 3
Beside that you can also consider passing the getRankingInfo=1 parameter with your search query, and filter the results displayed accordingly to the matching info returned for each hit within the _rankingInfo property.
firstMatchedWord: 2000
geoDistance: 0
geoPrecision: 1
nbExactWords: 2
nbTypos: 0
proximityDistance: 1
userScore: 9499
words: 2

Tableau, color-coded bar chart not working

Public workbook here. Source is Excel file.
I was able to create ordered bar chart based on (1) Location (2) Product
When I drag Above Three into Color, the graph is incorrect, how to troubleshoot?
Update
I made change such that Calculation computers based on Product, Above Three for each Location, at level Product.
However, Morton's still shows error.
The order in Mortons should descend, based on number of records, i.e.
Dark Chocolate
Beer
Toffee
Coffee
Fries
Rest of the Locations are correct, but only Mortons gives out-of-order products
Update2
Calculated Field Calculation3 = Index()
And I filter Calculation3 for 1 to 3, to display top 3 products
If I remove Calculation3 from filter, it gives correct order but it give ALL products, not the top three popular products (per Location).
I updated workbook to illustrate this. Please advise.
I don't know the purpose of the Index() field but that is creating your issue. Remove it from rows and the color appears to work the way you want it.
I hope this is what you are looking for
I have also published the file at the below address. You can take a view on that.
Tableau Wokbook
I achieved it by the following methods.
I changed the Calculation 3 field from Index() to RANK(SUM(NUMBER OF RECORDS)).
The calculation 3 was kept in between Location and period then edited the table calculation of calculation 3 by keeping the Addressing of the edit table calculation, having only the location and product as shown below and then Set the restarting every to Product.
You can check the workbook for more information

Crystal Reports XI - Group not returned when adding field which might be null

I'm a very new user of Crystal Reports with no training but with a very light background in programming.
I have been working on a report which should show me some information regarding the order status of parts within my company. I have modified an existing report which had a lot of the information I was looking for and have added several fields containing more information I want to look up (information like stock, delivery date, suppliers and partnumbers). I have one last field I want to add to the report, which shows me the name of the supplier where the part is ordered.
Problem:
When I add this field in the report, the groups where there is no information for this field disappear. When I remove the same field again, the missing groups return.
I have tried to look everywhere for an option or function which suppresses a group when a field is null but can not find anything. I also have tried to add an isNull function to return a certain value when the field is empty, but with no results. Unfortunately I can't review the returned values because the group has disappeared when I add the field.
This problem might have to do with the fact I started working from an existing report, but I have not been able to find a reason to believe so.
Update
I have made some pictures showing the problematic result and the SQL-Query (I can only link to the folder in Onedrive because I'm not allowed to post more than two links at the same time):
http://1drv.ms/1J1enHj

Sphinx Search Default Order

I just noticed something about Sphinx Search. If I choose a particular order, like relevance for example, it seems like if I have a number of items from 1 to 10, for some reason, the relevant returns that come back are still in a numbered order. i.e. The records will be in the 1-5 range instead of in the 6-10 range. Is there something I am missing or don't understand?
So, the only way I can get new results to show is to do a sort by ID DESC, but the problem there is I am only getting from the newest ID down and there isn't really any sort on relevance at that point.
Is there some kind of default sort on the back end that can be adjusted?

Range query with no dups

I have a collection that I would like to serve out as 'pages'. The collection could get quite large, I have read skip is not optimal in that case. I think range queries will work just fine in my case so I am going to try that route.
My collection will be sorted and paged on a timestamp field. I have implemented the API such that a user passes in a startDate and I will return a certain number ('limit', max of 1000) of items. However I am struggling with how to not get duplicates on each page if documents have the same time.
As an example (small page size to make it easy).
I have 6 documents let's docs 3 and 4 have the same time. If I ask for page one I will get the first three. However when I ask for page 2 with a startDate that it 'gte' the last doc on page one I will get a dup on page 2 as the last doc from page one will be that same as the first doc on page 2.
I cannot find a range query example anywhere that deals with dates, while not returning dups.