Thanks, folks

Code: Select all
$sql .= " AND pd.name LIKE '%" . $this->db->escape($keyword) . "%'";
Code: Select all
$sql .= " AND (pd.name LIKE '%" . $this->db->escape($keyword) . "%' OR p.model LIKE '%" . $this->db->escape($keyword) . "%')";
Code: Select all
$sql .= " AND pd.name LIKE '%" . $this->db->escape($keyword) . "%'";
Code: Select all
$sql .= " AND (pd.name LIKE '%" . $this->db->escape($keyword) . "%' OR p.model LIKE '%" . $this->db->escape($keyword) . "%')";
Many thanks, Phil. Can I second your request to Daniel?phpuk wrote:Hi,
There you go. You should now be able to search by product model as well as product name straight from the keyword search.
Daniel:
Can you please add this to the core so we can use it in replace of SKU as it was decided not to add SKU functionality.
Phil.
Code: Select all
if (!$description) {
$sql .= " AND pd.name LIKE '%" . $this->db->escape($keyword) . "%'";
} else {
$sql .= " AND (pd.name LIKE '%" . $this->db->escape($keyword) . "%' OR pd.description LIKE '%" . $this->db->escape($keyword) . "%')";
}
Code: Select all
if (!$description) {
$sql .= " AND (pd.name LIKE '%" . $this->db->escape($keyword) . "%' OR p.model LIKE '%" . $this->db->escape($keyword) . "%')";
} else {
$sql .= " AND (pd.name LIKE '%" . $this->db->escape($keyword) . "%' OR pd.description LIKE '%" . $this->db->escape($keyword) . "%' OR p.model LIKE '%" . $this->db->escape($keyword) . "%')";
}
Code: Select all
if (!$description) {
$sql .= " AND (pd.name LIKE '%" . $this->db->escape($keyword) . "%' OR p.model LIKE '%" . $this->db->escape($keyword) . "%' OR p.sku LIKE '%" . $this->db->escape($keyword) . "%')";
} else {
$sql .= " AND (pd.name LIKE '%" . $this->db->escape($keyword) . "%' OR pd.description LIKE '%" . $this->db->escape($keyword) . "%' OR p.model LIKE '%" . $this->db->escape($keyword) . "%' OR p.sku LIKE '%" . $this->db->escape($keyword) . "%')";
}
jfima wrote:howto for version 134
Open: catalog/model/catalog/product.php
Replace code block for methods getTotalProductsByKeyword, getProductsByKeyword:with code:Code: Select all
if (!$description) { $sql .= " AND pd.name LIKE '%" . $this->db->escape($keyword) . "%'"; } else { $sql .= " AND (pd.name LIKE '%" . $this->db->escape($keyword) . "%' OR pd.description LIKE '%" . $this->db->escape($keyword) . "%')"; }
There you go. You should now be able to search by product model as well as product name straight from the keyword search.Code: Select all
if (!$description) { $sql .= " AND (pd.name LIKE '%" . $this->db->escape($keyword) . "%' OR p.model LIKE '%" . $this->db->escape($keyword) . "%')"; } else { $sql .= " AND (pd.name LIKE '%" . $this->db->escape($keyword) . "%' OR pd.description LIKE '%" . $this->db->escape($keyword) . "%' OR p.model LIKE '%" . $this->db->escape($keyword) . "%')"; }
Daniel:
Can you please add this to the core so we can use it in replace of SKU as it was decided not to add SKU functionality.
Code: Select all
function moduleSearch() {
url = 'index.php?route=product/search';
var filter_keyword = $('#filter_keyword').attr('value')
if (filter_keyword) {
url += '&keyword=' + encodeURIComponent(filter_keyword);
}
var filter_category_id = $('#filter_category_id').attr('value');
if (filter_category_id) {
url += '&category_id=' + filter_category_id;
}
location = url;
}
Code: Select all
function moduleSearch() {
url = 'index.php?route=product/search';
var filter_keyword = $('#filter_keyword').attr('value')
if (filter_keyword) {
url += '&keyword=' + encodeURIComponent(filter_keyword) + '&model=1';
}
var filter_category_id = $('#filter_category_id').attr('value');
if (filter_category_id) {
url += '&category_id=' + filter_category_id;
}
location = url;
}
Ten kdo mě zná - ten ví, kdo mě nezná ten mě pozná a bude dělat že mě nezná jako ti co mě znají.
hmignon wrote:Dear is there an update for the latest version of opencart ?
Thx
Code: Select all
if (isset($data['filter_name']) && $data['filter_name']) {
if (isset($data['filter_description']) && $data['filter_description']) {
$sql .= " AND (LCASE(pd.name) LIKE '%" . $this->db->escape(strtolower($data['filter_name'])) . "%' OR p.product_id IN (SELECT pt.product_id FROM " . DB_PREFIX . "product_tag pt WHERE pt.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pt.tag LIKE '%" . $this->db->escape(strtolower($data['filter_name'])) . "%') OR LCASE(pd.description) LIKE '%" . $this->db->escape(strtolower($data['filter_name'])) . "%' OR LCASE(p.model) LIKE '%" . $this->db->escape(strtolower($data['filter_name'])) . "%')";
} else {
$sql .= " AND (LCASE(pd.name) LIKE '%" . $this->db->escape(strtolower($data['filter_name'])) . "%' OR p.product_id IN (SELECT pt.product_id FROM " . DB_PREFIX . "product_tag pt WHERE pt.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pt.tag LIKE '%" . $this->db->escape(strtolower($data['filter_name'])) . "%') OR LCASE(p.model) LIKE '%" . $this->db->escape(strtolower($data['filter_name'])) . "%')";
}
}
Cubecart to Opencart Migrations
KashFlow Accounting Integration with OpenCart
Users browsing this forum: No registered users and 17 guests