Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide protected products from autocomplete #2454

Closed
AlexanderWillner opened this issue May 14, 2023 · 1 comment
Closed

Hide protected products from autocomplete #2454

AlexanderWillner opened this issue May 14, 2023 · 1 comment
Labels
Milestone

Comments

@AlexanderWillner
Copy link
Contributor

AlexanderWillner commented May 14, 2023

Description: Hide protected products from autocomplete
Version: 2.8.12

Steps that will reproduce the problem?

  1. Enable autocomplete
  2. Type the title of a product that is protected

What is the expected result?
The list should only include products I'm allowed to query.

What happens instead?
A full list of products.

Possible workaround:
While some products are filtered already using SQL, we can't do this here as allowed groups are stored in the database as a PHP serialised array.

Any additional information:

In

$objProducts = Product::findPublishedByCategories($this->findCategories(), ['order' => 'c.sorting']);

the complete list of products are returned. A possibility to filter (to be discussed):

            $user_groups = FrontendUser::getInstance()->groups ?? [];
            $data = [];
            foreach($objProducts as $objProduct)
            {
                if ($objProduct->published && ($objProduct->guests || ! $objProduct->protected))
                {
                    // note: $this->iso_searchExact can't be used here
                    $data[] = $objProduct->{$this->iso_searchAutocomplete};
                }
                else
                {
                    $prod_groups = unserialize($objProduct->groups) ?? [];
                    $matches = array_intersect($prod_groups, $user_groups);
                    if ($matches)
                    {
                        $data[] = $objProduct->{$this->iso_searchAutocomplete};
                    }
                }
            }
            //$data = array_values($objProducts->fetchEach($this->iso_searchAutocomplete));
@aschempp aschempp added the bug label May 30, 2023
@aschempp aschempp added this to the 2.8 milestone May 30, 2023
@aschempp
Copy link
Member

aschempp commented Jun 6, 2023

Fixed in 626f227

@aschempp aschempp closed this as completed Jun 6, 2023
@aschempp aschempp modified the milestones: 2.8, 2.8.13 Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants