0

I'd like to pass the search query to the product page that is clicked on.

The reasoning is because if someone searches for a product, it may be on a grouped product page, so if they click on that result it just takes them to the top of that product page. I can add the anchor tags in the grouped product table, I just need the query passed so the page scrolls to that product.

For example, if someone searches for "Red Cup" and all of my cups are on a grouped product with 50 cups on, when they click the "Red Cup" on the results page it will take them to the top of the cup page. They've then got to scroll down to find "Red Cup" manually rather than the page scrolling to that product

0

Found the answer.

Needed to change the code in:

app/design/frontend/<VENDOR>/<THEME>/Magento_Catalog/templates/product/list.phtml

Copy to child theme.

To the link tags for the description and the image hover (depends on theme) I added <?php if (isset($_GET['q'])) { echo "#" . $_GET['q']; }; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.