Hello all,
v1.5.3.1
I am trying to find a way to include products options in the search results on my store. Here is my problem:
http://www.rosemaryandco.com/mh-oils-series-1
As you can see this product has many options assigned to it, and many customers are typing the colour to find it rather than the name of the product. I know an obvious solution is to create each colour as an individual product but this seems long winded. I have also found that adding product tags named as each colour makes the product appear in searching but this seems a dirty way of doing it.
Does anybody know of a way to solve this? I don't mind doing the research by looking into the core if someone can point me in the right direction.
Many thanks,
Oli
Hi agristar,
you can do this, but the solution is version independent as search changed a bit over the OpenCart versions.
For version 1.5.3.1, you would need to modify the "getProducts()" function in "\catalog\model\catalog\product\".
For example, if originally the search string was:
You would need it to look like this:
This will show you all products that have an option value of "red".
If you need this done for you, let me know.
- Mel
you can do this, but the solution is version independent as search changed a bit over the OpenCart versions.
For version 1.5.3.1, you would need to modify the "getProducts()" function in "\catalog\model\catalog\product\".
For example, if originally the search string was:
Code: Select all
"SELECT
p.product_id,
(SELECT AVG(rating) AS total
FROM oc_review r1
WHERE r1.product_id = p.product_id
AND r1.status = '1'
GROUP BY r1.product_id) AS rating
FROM oc_product p
LEFT JOIN oc_product_description pd ON (p.product_id = pd.product_id)
LEFT JOIN oc_product_to_store p2s ON (p.product_id = p2s.product_id)
LEFT JOIN oc_product_tag pt ON (p.product_id = pt.product_id)
WHERE
pd.language_id = '1'
AND p.status = '1'
AND p.date_available <= NOW()
AND p2s.store_id = '0'
AND ( LCASE(pd.name) LIKE '%red%'
OR LCASE(pt.tag) LIKE '%red%'
AND pt.language_id = '1')
GROUP BY p.product_id
ORDER BY p.sort_order ASC, LCASE(pd.name) ASC
LIMIT 0,15"
Code: Select all
SELECT
p.product_id,
(SELECT AVG(rating) AS total
FROM oc_review r1
WHERE r1.product_id = p.product_id
AND r1.status = '1'
GROUP BY r1.product_id) AS rating
FROM oc_product p
LEFT JOIN oc_product_description pd ON (p.product_id = pd.product_id)
LEFT JOIN oc_product_to_store p2s ON (p.product_id = p2s.product_id)
LEFT JOIN oc_product_tag pt ON (p.product_id = pt.product_id)
LEFT JOIN oc_product_option po ON (p.product_id = po.product_id)
WHERE
pd.language_id = '1'
AND p.status = '1'
AND p.date_available <= NOW()
AND p2s.store_id = '0'
AND ( LCASE(pd.name) LIKE '%red%'
OR LCASE(pt.tag) LIKE '%red%'
OR LCASE(po.option_value) LIKE '%red%'
AND pt.language_id = '1')
GROUP BY p.product_id
ORDER BY p.sort_order ASC, LCASE(pd.name) ASC
LIMIT 0,15
If you need this done for you, let me know.
- Mel
http://online.enterpriseconsulting.com.au
Site with OpenCart extensions & code downloads, many new extensions coming soon!
Follow us on twitter for more updates
Smart Search can do this, if you don't want to modify core files yourself. Otherwise, I would recommend using product tags like you suggested, rather than changing the MySQL queries, unless you really know what you're doing.
Who is online
Users browsing this forum: No registered users and 2 guests