Location: PHPKode > scripts > ColorShop > colorshop/templates/filter-product-by-attribute.php
<?php
	$all_attributes = explode(';', $_REQUEST['attr']);
	$args = array( 'post_type' => 'product' );
	//$lastposts = get_posts( $args );
	//foreach($lastposts as $post) :
	
	global $product;
	//FB::log($product, '$product');
	
	
	//setup_postdata($post);
	if($_REQUEST['attr']) {
		//$product = get_product($post);
		$attributes = $product->get_attributes();
		$product_arr = array();
		foreach ($attributes as $attr) {
			$name = $attr['name'];
			$value = $product->get_attribute($name);
			$value = str_replace(' ', '', $value);
			$product_arr[$name] = explode(',', $value);
		}
		$product_select_arr = array();
		$no_match = false;
		foreach ($all_attributes as $item) {
			$group = explode(':', $item );
			$value_current = $product_arr['pa_' . $group[0]];
			if (empty($value_current)) {
				$no_match = true;
				break;
			}
			$value_select = explode(',', $group[1]);
			$combine = array_intersect($value_current, $value_select);
				
			if (empty($combine)) {
				$no_match = true;
				break;
			}
		}
			
		if ($no_match) {
			continue;
		}
	}
	colorshop_get_template( 'content-product.php' );
	//endforeach;
?>
Return current item: ColorShop