Skip to content

Instantly share code, notes, and snippets.

@jedateach
Created April 19, 2013 02:03
Show Gist options
  • Save jedateach/5417600 to your computer and use it in GitHub Desktop.
Save jedateach/5417600 to your computer and use it in GitHub Desktop.
Draft code for filtering product variations on the front-end
<?php
if((isset($_SESSION['FilterTypes'])) && $types = $_SESSION['FilterTypes']){
$products = $products->innerJoin("ProductVariation","PV.ProductID = Product_Live.ID","PV");
$y = 0;
foreach ($types as $type){
$products = $products->innerJoin("ProductVariation_AttributeValues","PVA".$y.".ProductVariationID = PV.ID","PVA".$y);
$wheres = array();
foreach ($type as $value){
$wheres[] = "PVA".$y.".ProductAttributeValueID = ".$value;
}
$products = $products->where(implode("OR",$wheres));
$y++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment