Hello there,
I am thankful to Jesus Christ for this mod. We at www.amazingdiscoveries.org have just started to use it for many sites and it works quite well now.
We did come over one problem, and that is with linked products. The cat_filter() function searches for products matching the SITE_NAME in the description where the id of that category is the products master_category_id. If I confused you, don't worry. It will be easy when you'll see the code. The thing is that if I had a category that only had linked products then those products would not be showed in the extra site.
I had to make a few changes to the function so I'll just submit it and I hope that the author will make the changes for the next release. The changes occurred is where you see the RIGHT JOIN in the SQL.
Starting on line 34 of the cat_filter.php file:
PHP Code:
} elseif($sql == "select products_id from " . TABLE_FEATURED . " where status= 1 limit 1") {
// Special Query for the categories sideboxe/Featured Products
$sql = "SELECT f.products_id FROM " . TABLE_FEATURED . " f
INNER JOIN ".TABLE_PRODUCTS." p ON (f.products_id=p.products_id)
INNER JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
ON (cd.language_id=".$_SESSION['languages_id']."
AND cd.categories_description LIKE '%-".SITE_NAME."-%')
RIGHT JOIN zc_products_to_categories p2c ON (p2c.categories_id = cd.categories_id AND f.products_id = p2c.products_id)
WHERE status=1 limit 1";
} elseif($sql == "select s.products_id from " . TABLE_SPECIALS . " s where s.status= 1 limit 1") {
// Special Query for the categories sideboxe/Special Products
$sql = "SELECT s.products_id FROM " . TABLE_SPECIALS . " s
INNER JOIN ".TABLE_PRODUCTS." p ON (s.products_id=p.products_id)
INNER JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
ON (cd.language_id=".$_SESSION['languages_id']."
AND cd.categories_description LIKE '%-".SITE_NAME."-%')
RIGHT JOIN zc_products_to_categories p2c ON (p2c.categories_id = cd.categories_id AND s.products_id = p2c.products_id)
WHERE status=1 limit 1";
} else { // Query with categories but not descriptions
$str_pos_cats = strpos($sql_lower,TABLE_CATEGORIES . ' c');
if($str_pos_cats!==false&&$str_pos_cats<$str_pos_where) {
$add_pos = $str_pos_products + strlen(TABLE_CATEGORIES . ' c');
$str_pos_coma = strpos($sql_lower,',',$add_pos);
if($str_pos_coma!==false) {
$add_pos = $str_pos_coma;
}
if(($str_pos_where!==false)&&(($str_pos_coma===false)||($str_pos_where<$str_pos_coma))) {
$add_pos = $str_pos_where;
}
$sql = substr($sql,0,$add_pos).
" INNER JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
ON (c.categories_id = cd.categories_id
AND cd.language_id=".$_SESSION['languages_id']."
AND cd.categories_description LIKE '%-".SITE_NAME."-%') ".
substr($sql,$add_pos);
}
}
if($fix==1) {
if(preg_match("/^select p2c.categories_id from ".TABLE_PRODUCTS." p, ".TABLE_PRODUCTS_TO_CATEGORIES." p2c ".
"where p.products_id = '[0-9]+' and p.products_status = '1' ".
"and p.products_id = p2c.products_id limit 1$/",$sql)) {
$sql = str_replace(TABLE_PRODUCTS_TO_CATEGORIES." p2c ",TABLE_PRODUCTS_TO_CATEGORIES." p2c
INNER JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
ON (p2c.categories_id=cd.categories_id
AND cd.language_id=".$_SESSION['languages_id']."
AND cd.categories_description LIKE '%-".SITE_NAME."-%')
INNER JOIN ".TABLE_CATEGORIES." as c ON (cd.categories_id=c.categories_id AND c.categories_status=1)",$sql);
} else {
$add_pos = $str_pos_products + strlen(TABLE_PRODUCTS . ' p');
$str_pos_coma = strpos($sql_lower,',',$add_pos);
if($str_pos_coma!==false) {
$add_pos = $str_pos_coma;
}
if(($str_pos_where!==false)&&(($str_pos_coma===false)||($str_pos_where<$str_pos_coma))) {
$add_pos = $str_pos_where;
}
$sql = substr($sql,0,$add_pos).
" INNER JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
ON (cd.language_id=".$_SESSION['languages_id']."
AND cd.categories_description LIKE '%-".SITE_NAME."-%')
RIGHT JOIN ".TABLE_PRODUCTS_TO_CATEGORIES." p2c
ON (p2c.categories_id = cd.categories_id
AND p.products_id = p2c.products_id) ".
substr($sql,$add_pos);
}
God bless you all,
Iasmin from AmazingDiscoveries.org
Bookmarks