Created
May 31, 2012 16:06
-
-
Save GreatPotato/2844430 to your computer and use it in GitHub Desktop.
Gets a list of attributes that are unique to the products in a given category
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function list_unique_values_in_category($name, $category = NULL) | |
{ | |
$category = (int) $category; | |
$values = Db_DbHelper::scalarArray(' | |
SELECT DISTINCT value, t4.name | |
FROM shop_product_properties t1 | |
LEFT JOIN shop_products_categories t3 | |
ON t1.product_id = t3.shop_product_id | |
LEFT JOIN shop_categories t4 | |
ON t3.shop_category_id = t4.id | |
WHERE t4.id = :cat_id | |
AND t1.name = :name | |
', array('name'=>$name,'cat_id'=>$category)); | |
$result = array(); | |
foreach ($values as $value) | |
{ | |
if (strlen($value) && !in_array($value, $result)) $result[] = $value; | |
} | |
sort($result); | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment