wp query – Getting list of categories that have posts in search results

Looking for a solution for the following problem.

I am trying to create a list of categories that contain posts in a results page. Ideally this would also contain a post count.

Up to this point I would run a query using 'post_per_page'=>-1', 'fields'->'ids' only, then using a loop I would use the get_the_category(), get_ancestors() and populate an array along with counts. Up to recently this used to be working nicely, however, the website is growing a lot larger by the day, so this is not feasible any more since it takes a lot of time. I knew in the beginning that at some point this would come to a stall, however, this came earlier than I was expecting.

From what I realized, using the whole WP_Object for each post is too heavy for the server if the results exceed 2k in count, but on the other hand only using 'fields->'ids' forces me to use loops – which is also heavy.

One solution I ended up with, is limiting results to the first 1000, but obviously this would mean, that the counts in the categories will not be accurate, and some categories might be left out, if they exist in results that exist after the first thousand.

I am willing to sacrifice the counts as long as I am able to populate a complete category list.

Has anyone done anything similar? Looking forward to your replies.

sharepoint online – Can we use Microsoft Search Connectors as a result source for Classic search

Is it possible to use connectors as one of the result sources in SharePoint online?

We create a new connector and we are able to configure that as a result source for Microsoft Search(modern search experience) in SharePoint online.

Is it possible to add this as a result source in Classic search

Custom module sort and search filter not working

I’ve created a custom module.

The sorting and search filter not working on the grid page.

<arguments>
<argument name="id" xsi:type="string">testGrid</argument>
<argument name="dataSource" xsi:type="object">VendorNameModuleNameModelResourceModelTestCollection</argument>
<argument name="default_sort" xsi:type="string">id</argument>
<argument name="default_dir" xsi:type="string">desc</argument>
<argument name="save_parameters_in_session" xsi:type="boolean">true</argument>
<argument name="use_ajax" xsi:type="boolean">true</argument>
<argument name="grid_url" xsi:type="url" path="*/*/grid"><param name="_current">1</param></argument>
</arguments>

table sort and search filter not working

magento2 – Don’t Sort by Name when have Mysql Search Engine Magento 2.4.1

I installed the Weltpixel AjaxLayeredNavigation extension and with the Swissup extension of Mysql Legacy Search Engine, having both activated when I want to sort by name gives me the following SQL error: Column not found: 1054 Unknown column ‘nameasc’ in ‘order clause’

If someone has gone through a similar error please it would be of great help.

Magento2: How to get attribute EAN and implement to search URL

I have simple script to display others sellers the same product on product page.

<span><?= /* @escapeNotVerified */ __('Total other sellers:') ?>    
<a class="others-sellers"
                                   href="<?= /* @escapeNotVerified */ $this->getUrl('catalogsearch/result/?q=') ?>"
                                   title="<?= /* @escapeNotVerified */ $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>">
                                    <?= /* @escapeNotVerified */ __('17') ?>
                                </a>
</span>

Issue is related to code:

<a class="others-sellers"
                                       href="<?= /* @escapeNotVerified */ $this->getUrl('catalogsearch/result/?q=') ?>"

This PHP code generate for me link:

https://mywebsite.pl/catalogsearch/result/?q=/

To end URL I need also get attribute EAN and add to URL.
https://mywebsite.pl/catalogsearch/result/?q=83748273423333/

Here I have code how to get EAN. But can anyone help how can i implement this into the code?

<?php $_productNameStripped = $block->stripTags($_product->getEan(), null, true); ?>
            <?php /* @escapeNotVerified */  echo $_helper->productAttribute($_product, $_product->getEan(), 'ean'); ?>

typescript – Rxjs search in Angular

I created an rxjs search for a hiring company, but I got rejected for the following reason:
-performance issue on a bigger data set.
-bugs

My question is how can I make this code better for the next time if I have similar task?

brands = These should be populated from the brand property from the collection of products.

The search should match using the name, description and brand
properties.

  • The search should not fire unless a minimum of three characters have been typed.
  • The search should only fire a maximum of once per 400 milliseconds.

If searching for “xxx” with the brand selected as “xxx” and In Stock, then only products matching all three filters

const stackoverflowFilter = (filter: ISearch) => {
  return (product: IProducts): boolean => {
    return ((
      (
        (product.name.toLowerCase().indexOf(filter.input.toLowerCase()) !== -1) ||
        product.description.toLowerCase().indexOf(filter.input.toLowerCase()) !== -1 ||
        product.brand.toLowerCase().indexOf(filter.input.toLowerCase()) !== -1) &&
      product.brand.toLowerCase().indexOf(filter.select.toLowerCase()) !== -1 &&
      (filter.radio === 'all' ? true : filter.radio === 'in-stock' ? product.quantity > 0 : product.quantity === 0)
    )
    )
  };
};

export interface ISearch { input: string; select: string; radio: string }



> public getStackoverflow(): Observable<Stackoverflow()> {
>         return of((
>           {
>             id: "1",
>             name: "This is just test data",
>             price: "89.9",
>             description: "test data",
>             brand: "stackoverflow",
>             quantity: 4
>           }....))}



 this.stackoverflow$ = this.service.getStackoverflow();

    this.stackoverflow$.pipe(
      tap((prod) => {
        this.stackoverflow = prod;
        this.brands = this.stackoverflow.map(({ brand }) => brand).reduce((prev, cur) => {
          if (prev.indexOf(cur) < 0) prev.push(cur);
          return prev;
        }, ());
      }),
      concatMap(() =>
        this.search$.pipe(
          debounceTime(400),
          distinctUntilChanged(),
          switchMap((search: string) =>
            iif(() => search.length >= 3,
              this.stackoverflow$.pipe(
                map(stackoverflow=> stackoverflow.filter(stackoverflowFilter(this.filter))),
                distinctUntilChanged((curr, prev) => curr === prev),
              ),
              this.stackoverflow$.pipe(
                filter(() => search.length === 0),
              )
            )
          )
        ))
    ).subscribe(
      stackoverflow=> { this.stackoverflow= stackoverflow; },
      (err) => throwError(err)
    );