I am trying to amend my search code to include the category name in the criteria.
here's what I have done so far but it isn't working.
I added cd.categories_name to the end of the select string:
I added a JOIN to the categories description table:PHP Code:$select_str = "SELECT DISTINCT " . $select_column_list .
" m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_price_sorter, p.products_qty_box_status, p.master_categories_id, cd.categories_name ";
and lastly added the OR check of the keyword matching the cd.categories_name :PHP Code:$from_str = "FROM " . TABLE_PRODUCTS . " p" .
" LEFT JOIN " . TABLE_MANUFACTURERS . " m USING(manufacturers_id)" .
" LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id" .
" JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id" .
" JOIN " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id" .
//added line below
" JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd ON p.master_categories_id = cd.categories_id" .
" LEFT JOIN " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " mtpd ON mtpd.products_id= p2c.products_id AND mtpd.language_id = :languagesID" .
($filter_attr == true ? " JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " p2a on p.products_id = p2a.products_id" .
" JOIN " . TABLE_PRODUCTS_OPTIONS . " po on p2a.options_id = po.products_options_id" .
" JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov on p2a.options_values_id = pov.products_options_values_id" .
(defined('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK') ? " JOIN " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " p2as on p.products_id = p2as.products_id " : "") : '');
I thought that would do it.PHP Code:$where_str .= "(pd.products_name LIKE '%:keywords%'
OR p.products_model
LIKE '%:keywords%'
OR m.manufacturers_name
LIKE '%:keywords%'
OR cd.categories_name
LIKE '%keywords%'";
page doesnt error so I assume its accepting the query Ok, maybe i'm joining wrong? Can anyone see what I am doing incorrect?
Thanks in advance.
Phil


Reply With Quote
