Skip to content

Commit

Permalink
Change the table aliases in the product filter
Browse files Browse the repository at this point in the history
fixes #2043
  • Loading branch information
aschempp committed May 29, 2019
1 parent e684114 commit 0ddbd04
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,53 +96,53 @@ protected function getUsedValuesForAttribute($attribute, array $categories, $new

// Apply new/old product filter
if (self::FILTER_NEW === $newFilter) {
$sqlWhere .= ' AND p1.dateAdded>=' . Isotope::getConfig()->getNewProductLimit();
$sqlWhere .= ' AND tl_iso_product.dateAdded>=' . Isotope::getConfig()->getNewProductLimit();
} elseif (self::FILTER_OLD === $newFilter) {
$sqlWhere .= ' AND p1.dateAdded<' . Isotope::getConfig()->getNewProductLimit();
$sqlWhere .= ' AND tl_iso_product.dateAdded<' . Isotope::getConfig()->getNewProductLimit();
}

if (BE_USER_LOGGED_IN !== true) {
$published = "
AND p1.published='1'
AND (p1.start='' OR p1.start<'$time')
AND (p1.stop='' OR p1.stop>'" . ($time + 60) . "')
AND tl_iso_product.published='1'
AND (tl_iso_product.start='' OR tl_iso_product.start<'$time')
AND (tl_iso_product.stop='' OR tl_iso_product.stop>'" . ($time + 60) . "')
";
}

if (0 !== $atypeCount) {
$typeConditions[] = 'p1.type IN (' . implode(',', $attributeTypes) . ')';
$typeConditions[] = 'tl_iso_product.type IN (' . implode(',', $attributeTypes) . ')';
}

if (0 !== $vtypeCount) {
$typeConditions[] = 'p2.type IN (' . implode(',', $variantTypes) . ')';
$join = 'LEFT OUTER JOIN tl_iso_product p2 ON p1.pid=p2.id';
$categoryWhere = 'OR p1.pid IN (
$typeConditions[] = 'translation.type IN (' . implode(',', $variantTypes) . ')';
$join = 'LEFT OUTER JOIN tl_iso_product translation ON tl_iso_product.pid=translation.id';
$categoryWhere = 'OR tl_iso_product.pid IN (
SELECT pid
FROM tl_iso_product_category
WHERE page_id IN (' . implode(',', $categories) . ')
)';

if (BE_USER_LOGGED_IN !== true) {
$published .= " AND (
p1.pid=0 OR (
p2.published='1'
AND (p2.start='' OR p2.start<'$time')
AND (p2.stop='' OR p2.stop>'" . ($time + 60) . "')
tl_iso_product.pid=0 OR (
translation.published='1'
AND (translation.start='' OR translation.start<'$time')
AND (translation.stop='' OR translation.stop>'" . ($time + 60) . "')
)
)";
}
}

$result = \Database::getInstance()->execute("
SELECT DISTINCT p1.$attribute AS options
FROM tl_iso_product p1
SELECT DISTINCT tl_iso_product.$attribute AS options
FROM tl_iso_product
$join
WHERE
p1.language=''
AND p1.$attribute!=''
tl_iso_product.language=''
AND tl_iso_product.$attribute!=''
" . $published . '
AND (
p1.id IN (
tl_iso_product.id IN (
SELECT pid
FROM tl_iso_product_category
WHERE page_id IN (' . implode(',', $categories) . ")
Expand Down

0 comments on commit 0ddbd04

Please sign in to comment.