<p>Ended up creating a custom plugin to achieve this functionality. Also added some custom pagination logic. Set up a gist showing the variable and service files of the plugin as well as an example twig template to output the results.</p>

<p><a href="https://gist.github.com/matt-adigital/e79b2fd2e14327b3f306a907f4e7e02e" rel="nofollow noreferrer">https://gist.github.com/matt-adigital/e79b2fd2e14327b3f306a907f4e7e02e</a></p>

<p>All working well but it would be great if this was in core or just a little easier to implement. If we could leverage Crafts pagination for our own usage by passing in a dataset instead of being confined to the craft\elements\db\ElementQueryInterface object, then this would be a big help.</p>

<p>Another option could be to allow craft\elements\db\ElementQuery to accept multiple elementTypes or a null value, tried to submit with null but it is in fact required to be a string.</p>

<p>Hopefully anyone else who wants to use this functionality without going down the Algolia route will find this helpful.</p>

CC BY-SA 4.0
2019-08-27T13:07:57.890Z
Nice, just what I am looking for! But how add this as a plug-in? Or must this snippet added as an module? And is this snippet for craft 3 and commerce 2?
Maarten Heideman
CC BY-SA 4.0
2018-12-10T11:36:46.803Z
2018-12-10T11:36:46.803Z
Matt Shearing
<p>Unfortunately you would need to do 2 element query searches and combine the results on the front end.</p>

<p>Most developers tend to go for <a href="https://algolia.com" rel="nofollow noreferrer">https://algolia.com</a> when they want fast advanced search, including searching across elements. </p>

<p>Probably easiest to get started by searching for an Algolia plugin in the plugin store. I only know <a href="https://github.com/Rias500/craft-scout" rel="nofollow noreferrer">https://github.com/Rias500/craft-scout</a> for Craft 3 at the moment.</p>

CC BY-SA 4.0
2018-12-07T11:58:40.407Z
Thank you for your response Luke. Would be nice to have a built in function for this in the future if possible. Combining on the front end seems like it would cause pagination issues. Now that I know there is nothing available in core though I might try to throw together a plugin to achieve this. Trying to avoid adding any additional monthly costs such as Algolia for this client. Thanks again.
Matt Shearing
CC BY-SA 4.0
2018-12-07T11:11:19.503Z
2018-12-07T11:11:19.503Z
Luke Holder
<p>Is there any way of searching both entries and products at the same time? Wanting a single search on the site which will return all entries and products containing the searched for phrase.</p>

<p>Looked at combining the results from <code>craft.entries.search()</code> and <code>craft.products.search()</code> but this stops us from using pagination which we would like to have. Anybody got a solution or suggestions?</p>

<p>Would prefer not to split into 2 search pages if possible. Thank you.</p>

<entries><plugin-craftcommerce><search><pagination><products>
Search products and entries with pagination
# Search products and entries with pagination

(Asked by: username_0 on 2018-12-07)

Is there any way of searching both entries and products at the same time? Wanting a single search on the site which will return all entries and products containing the searched for phrase.

Looked at combining the results from `craft.entries.search()` and `craft.products.search()` but this stops us from using pagination which we would like to have. Anybody got a solution or suggestions?

Would prefer not to split into 2 search pages if possible. Thank you.

**Tags:** entries, plugin-craftcommerce, search, pagination, products


---

## 2 answers

### Answer by username_0 on 2018-12-10. Score: 2 | Accepted answer

Ended up creating a custom plugin to achieve this functionality. Also added some custom pagination logic. Set up a gist showing the variable and service files of the plugin as well as an example twig template to output the results.

<https://gist.github.com/matt-adigital/e79b2fd2e14327b3f306a907f4e7e02e>

All working well but it would be great if this was in core or just a little easier to implement. If we could leverage Crafts pagination for our own usage by passing in a dataset instead of being confined to the craft\elements\db\ElementQueryInterface object, then this would be a big help.

Another option could be to allow craft\elements\db\ElementQuery to accept multiple elementTypes or a null value, tried to submit with null but it is in fact required to be a string.

Hopefully anyone else who wants to use this functionality without going down the Algolia route will find this helpful.

> **Comments:**
> **username_1**: Nice, just what I am looking for! But how add this as a plug-in? Or must this snippet added as an module? And is this snippet for craft 3 and commerce 2?  

---

### Answer by username_2 on 2018-12-07. Score: 1

Unfortunately you would need to do 2 element query searches and combine the results on the front end.

Most developers tend to go for <https://algolia.com> when they want fast advanced search, including searching across elements.

Probably easiest to get started by searching for an Algolia plugin in the plugin store. I only know <https://github.com/Rias500/craft-scout> for Craft 3 at the moment.

> **Comments:**
> **username_0**: Thank you for your response Luke. Would be nice to have a built in function for this in the future if possible. Combining on the front end seems like it would cause pagination issues. Now that I know there is nothing available in core though I might try to throw together a plugin to achieve this. Trying to avoid adding any additional monthly costs such as Algolia for this client. Thanks again.  

---

