Latest Articles
So far this was never an issue, there were problems with uploading modules via the installer because of the ftp connection but you could allways install ocmods without any issue. However, some .. Read More
People had this issue so many times I thought I would write a bit about it. The  types of issues with opencart's 2.x modification system that I identified so far are: 1. Old Vqmod .. Read More
This small tutorial will show you how to manually add custom links to the default top menu in opencart. If you dont want to go trough all the hustle and would like to be able to completly customize.. Read More
To enable seo urls in opencart navigate in admin to system > settings , edit the store and on the server tab of the store settings you will find "Use SEO urls", set it to yes. So far e.. Read More
All Articles

How to search by product code in opencart 1.5.2.x

By default the opencart search only works for product name and if selected, it also searches in the product description.

If you want the search to also work for the product code (model), here are the modifications you need to make in order for it to work.

Edit the file catalog/model/catalog/product.php and 2 times you will find this code:

foreach ($words as $word) {
if (!empty($data['filter_description'])) {
$implode[] = "LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%' OR LCASE(pd.description) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%'";
} else {
$implode[] = "LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%'";
}
}

and both times, replace it with the following code: 

foreach ($words as $word) {
if (!empty($data['filter_description'])) {
$implode[] = "LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%' OR LCASE(pd.description) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%' OR LCASE(p.model) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%'";
} else {
$implode[] = "LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%' OR LCASE(p.model) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%'";
}
}

And that is all, now the search function will also work for product code.

Posted by Flo

Related Articles

Many people ask about the setting on how many products are beeing displayed per row in opencart modules or category listings. Well there is no such setting, I mean there might be in some custom themes but now Im reffering strictly to the opencart default theme. The number of products displayed per row is influenced by the width of the individual product box which is set in the stylesheet.css of the default theme (catalog/view/theme/default/stylesheet/stylesheet.css). Change the number of products per row for modules display (Like latest, Featured, Bestsellers):  In stylesheet.c..
0 comments on this article - view comments